Operating System - HP-UX
1828218 Members
2048 Online
109975 Solutions
New Discussion

Re: Cleint-Server Question

 
SOLVED
Go to solution
Becke
Super Advisor

Cleint-Server Question

Guys couple of questions,

When a client and server applications are installed on the same host,

Q, Do they need to use ports to talk to each other? does it have to use tcp/ip?

Qestion 2. How does a server knows and fulfils client's request on the same host?

Please let me know

Cheers
Raf
27 REPLIES 27
njia_1
Trusted Contributor
Solution

Re: Cleint-Server Question

Hi

For communications between application on same host there are few different way to implement the IPC (inter process communication) TCP/IP is one of the commond methods. Others like pipes, FIFOs(named pipes) and for system V there are few more like message queues, Semaphores and Shared Memory.
Do a search on google interprocess communication and you will find a lot of information.

second question,

Usually there is a communication protocol being used by both clients and servers like HTTP, FTP this protocol defines commands, data structures format how to handle errors and which port server should listen on, etc etc. Everything is already defined before client can talk to server and server can process any requests from clients. Just like if you only speack English, you can only talk to someone speaks English as well. In this case, English is the protocol.
A. Clay Stephenson
Acclaimed Contributor

Re: Cleint-Server Question

When on the same host, the client/server do not have to use ports to communucate with each other. That can use named pipes, IPC messages, a simple file, or even shared memory. However, it's very common to use tcp ports local-to-local as well as local-to-remote client/server pairs. After all, why use two methods and invent the wheel twice when one method will work?
If it ain't broke, I can fix that.
Arunvijai_4
Honored Contributor

Re: Cleint-Server Question

Hi Raf,

Q1, Do they need to use ports to talk to each other? does it have to use tcp/ip?

Not necessarily TCP/IP, It can be any of IPC methods like, named pipes, fifo, etc.. Also, they can communicate via TCP/IP as well.

2. How does a server knows and fulfils client's request on the same host?

There maynot be any difference between same host and others(sometimes, may be). After all,
It(Server) is designed to serve to the clients.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Becke
Super Advisor

Re: Cleint-Server Question


Thanks Guys for your quick responses, I'm doing lot of reading on the internet to gain appropriate knowledge, I will be getting back with some more questions once I'm finished with my reading...

Thanks a lot, I will assign points soon...
Becke
Super Advisor

Re: Cleint-Server Question


Guys,

When client-server is talking to each other on the same host using tcp/ip, then what is the example of using TCP/IP on the same host?? is it when it uses ports to communicate each other or something else???
Bharat Katkar
Honored Contributor

Re: Cleint-Server Question

Hi Raf,
Find attached doc on Network Ports.
Thought this could be helpful.
Regards,
You need to know a lot to actually know how little you know
Arunvijai_4
Honored Contributor

Re: Cleint-Server Question

Hi Raf,

You asked,

When client-server is talking to each other on the same host using tcp/ip, then what is the example of using TCP/IP on the same host?? is it when it uses ports to communicate each other or something else???

It depends, for example, you are running Apacher server on HP-UX and using Mozilla in the same host, you request a page or doing kernel tuning with kcweb. Thsese stuffs can't be done thro' other IPC mechanisms.

Hope this is clear.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
njia_1
Trusted Contributor

Re: Cleint-Server Question

Hi there

Not sure about your last question, if you just want to see an exmaple of two programs talking to each other using TCP/IP but they both running on the same host. The quickest example is try this

# telnet localhost

and then try

# netstat -a | grep telnet

and you will see something like following

netstat -a | grep telnet
tcp 0 0 localhost.58746 localhost.telnet ESTABLISHED
tcp 0 0 localhost.telnet localhost.58746 ESTABLISHED
tcp 0 0 *.telnet *.* LISTEN
tcp 0 0 primux.telnet .59217 ESTABLISHED

It tells you that there is a TCP/IP connection been established betweel localhost, port 58746 and localhost 23(telnet)
Arunvijai_4
Honored Contributor

Re: Cleint-Server Question

Hi Raf,

Here is a good link describes about a typical C&S app.

http://penguin.dcs.bbk.ac.uk/academic/networks/application-layer/client-server/index.php

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Becke
Super Advisor

Re: Cleint-Server Question


Thanks a lot to all of you, your information has certainly helped me and I feel more comfortable now, I'm reading the doco and If I will have any other query I will post it tommorow..

We have an excellent and helpful team here guys. I appreciate everyone's quick response and help..

Cheers,
Raf
Muthukumar_5
Honored Contributor

Re: Cleint-Server Question

Good. You can check port statistics with,

# netstat -na | grep portno

# lsof -i:port

You have to install lsof. It will be helpful for your requirement always as a monitoring tool.

Keep continuing your questions here.

--
Muthu
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor

Re: Cleint-Server Question

Hi Raf,

"lsof" is a nifty utility in HP-UX. You can get lot of information with that. Download and install from,

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.75/


-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: Cleint-Server Question

Hi Raf,

A must for Socket programmers in HP-UX,

BSD Sockets Interface Programmer's Guide:
http://docs.hp.com/en/B2355-90136/index.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Becke
Super Advisor

Re: Cleint-Server Question

Guys,

I need to know exactly that, How does the server know that it has to fulfil clients services.

Please let me know about the above as I'm still not clear.

Cheers,
Raf
Steven E. Protter
Exalted Contributor

Re: Cleint-Server Question

Shalom to you Raf,

The answer to your last question is totally dependent on the the application.

On a basic level, the server listens on a network port. The client is configured to send a request on that network port.

The server is coded to know how to respond to a properly formed request.

Lets use an oracle example.

The oracle db server is listening on port 1521.

A client using the oracle client software performs a request for data, in the form of a sql query and sends it to the database server and port defined in a configuration file, which sets up communication with the server.

The server receives the request, prioritizes it and answers the request with the data that was requested in the sql query.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Becke
Super Advisor

Re: Cleint-Server Question


Thanks for your response Steven, so in simple words you say that "if the server is coded to know how to respond to a properly formed request then it will fulfil the request right?

My other question is,

How does your browser know hot to find and talk to the http server?

I'm doing some reading on internet but your help would be appreciated..

Cheers,
Raf
njia_1
Trusted Contributor

Re: Cleint-Server Question

Hi Raf,

Basically, your web broswer for example IE needs to know the IP address of the web server you want to open, it uses DNS to find out the IP address and then it use HTTP protocol talks to web server. Any web servers understand HTTP protocol and that is why IE can talk to web servers just like we can discussed different topics here because we all speak English.

Have a look here.
http://tldp.org/HOWTO/Unix-and-Internet-Fundamentals-HOWTO/internet.html
Becke
Super Advisor

Re: Cleint-Server Question


Thanks mate, you have given the answer and my reading is certainly helping me a lot along the way...

If I will have any query I will be posting more...

Kind Regards,
Raf
Arunvijai_4
Honored Contributor

Re: Cleint-Server Question

Hi Raf,

Some interesting reading,

http://computer.howstuffworks.com/web-server.htm
http://computer.howstuffworks.com/web-page.htm

Generic, http://computer.howstuffworks.com/internet-channel.htm

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Becke
Super Advisor

Re: Cleint-Server Question


Thanks Arun....

Raf
Becke
Super Advisor

Re: Cleint-Server Question


Guys,

I have done some reading and found out that, when client-server applications communicate they also refer to the "/etc/services" file to lookup the port number for the specific application, so the data can be sent through tcp/ip layer to the destination port....

I didn't know the function of "/etc/services" file,

Thanks for everyone's help and prompt response, through everyone's help, I have gained excellent knowledge.

We have an excellent team here...

Cheers,
Raf
njia_1
Trusted Contributor

Re: Cleint-Server Question

Hi Raf,

/etc/services is just an ascii file you can use vi or any other editor to open it.

you will see something like

.........
telnet 23/tcp # Virtual Terminal Protocol
.............................

this means "telnet" is using port 23 and it is using TCP. This is just like a very samll DNS systems, people use names of each different services and computers use port numbers like 23 for telnet and 80 for http.

Some service uses both TCP and UDP protocol, like DNS
domain 53/tcp nameserver # Domain Name Service
domain 53/udp nameserver #

one network connection can be unique identified by local ip, local port, protocol, remote ip and remote port
Becke
Super Advisor

Re: Cleint-Server Question


Gday Njia,

Thanks for your elaboration and help, I have actually viewed the /etc/services file and now I have a better understanding, specially after your and everyone else's explaination.

Keep it up team, I really appreciate everyone's prompt resonse and help for sharing your their knowledge.

Cheers,
Raf

James R. Ferguson
Acclaimed Contributor

Re: Cleint-Server Question

Hi Raf:

A port number does not have to be present in '/etc/services' for it to be used. The file states intention only.

The so-called well-known-ports range from 0-1023 and are only usable by root processes.

So-called registered-ports fall in the range 1024 through 49151.

Port numbers from 49152-65535 are called dynamic ports or private ports.

http://www.iana.org/assignments/port-numbers

Regards!

...JRF...