Vanja Djurdjevic
Vanja Djurdjevic

Reputation: 1

Server - client communication on the same host

I'm writting a program that simulates nodes in network. Every node is listening to some port on local for incoming requests. If a request is received it replies to sender of the request. The reply is sent after a socket is created associated with the address of the sender of the request. Since sender is using some port on localhost and has used bind to listen to id, trying to bind to the same port with an other process results in a messages that states that the port is already taken (bound). How should I solve this in order to be able to simulate server/client on the same machine? I am using UDP protocol for this program.

Upvotes: 0

Views: 148

Answers (1)

HenryTK
HenryTK

Reputation: 1287

You solve this by using different ports for client and server interaction. A useful example would be how client and server interact during DHCP. The client sends requests via UDP on port 67 and the server sends responses back via UDP on port 68.

Upvotes: 1

Related Questions