This content has been marked as final. Show 2 replies
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