Reputation: 6494
I see that some applications using TCP can be configured to bind to multiple ports. Does this mean that they open multiple TCP sockets, or it is possible to open a single socket and bind it to many local ports?
Thanks.
Upvotes: 1
Views: 84
Reputation: 73304
A TCP socket can only be bound to a single port. In particular, if you try to bind an already-bound TCP socket to a second port, bind()
will return -1 and set errno
to EINVAL
.
Servers that accept incoming TCP connections on multiple ports are doing it by creating multiple TCP sockets.
Upvotes: 1