Multiple sockets, same port

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multiple sockets, same port

3,351 Views
tobiasplayer
Contributor I
Hi,
 
  What is the proper method for opening several passive sockets listening on the same port with the mini-sockets API. Do I start one listen socket and try to spawn the connections from that or do I need to open a different listen socket for every connection I wish to allow?
 
Thanks,
Bob
Labels (1)
0 Kudos
2 Replies

388 Views
mjbcswitzerland
Specialist V
Hi Bob

Essentially it is only possible to have one listener on a particulat port.

Generally the listener then checks the source port to see whether there is already a connection. If not, it needs to 'create' a new connection (probably spawn in your terminology) to which it assigns the source port as reference.
Further frames to the particular open connection are then handled by the session (thread or whatever) assigned to the source port.
When the connection terminates, the connection resources can be freed.

The system must be dimensioned to be able to handle the expected number of parallel connections expected to be encountered. If a new connection is not possible since the connection limit has been reached the connection can be refused by sending a RST.

Regards

0 Kudos

388 Views
tobiasplayer
Contributor I
Thanks Mark!
 
   I pretty much got through it by the end of the day yesterday, but you have confirmed what I did. I have done this kind of thing many times using standard Berkeley sockets, but between their added twist of having to use a callback routine for everything and and the examples using their "msring" ring buffer code, I was thoroughly confused.I needed more control over the buffer assignments so I ended writing a special version of some of the msring functions and then took more control in my app.
 
Bob
0 Kudos