I have a doubt. Consider, a program is having two threads. One is listening on port X, Say 1500. When the user interacts with the program's second thread, it gets data from some other machine on port X i.e., same 1500. is this possible ?
If this program is running in more number of machines... Is it possible that a program running as server can act as client for another server.. (On SAME port) ??? Note: I have multiple threads to handling incoming requests for server. But, the Second thread (Client) is only one at a time..
Please Help Me...
Thanking you in advance..
R. Kaja Mohideen
When a program acts as a server it is "listening" for a request on a given port. When a program acts as a client, requesting services, it "targets" a given port on another (or even the same) machine. The client's socket (ipaddress:port pair) is independent of the server's socket, unless both the client and server are on the same ip address, in which case the ports must be different.
Yes, a program can act as both a client and a server. As a matter of fact this is exactly what occurs in peer-to-peer data communications