views:

27

answers:

1

Hi Geeks,

I put a TCP server and client code in PIC controller. Now just wanted to know, can the same device run both client and server at sametime? And if possible can we use the same socket on a TCP stack for server and for client?

A: 

Your question about using the same socket doesn't really make any sense since presumably the client and the server are separate processes, so they cannot share the exact same socket. For a server, you usually create a socket, then bind it to a specific port, and accept connections. For the client, you create a socket, and connect to a specified address (an IP address and port pair for a TCP/IP connection).

The same device can run a TCP server and client at the same time. You can start the server listening on a specific port and then connect the client to the same port, and the two programs will communicate with each other.

RarrRarrRarr