Multiple sockets, same port

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Multiple sockets, same port

3,957件の閲覧回数
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
ラベル(1)
0 件の賞賛
返信
2 返答(返信)

994件の閲覧回数
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 件の賞賛
返信

994件の閲覧回数
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 件の賞賛
返信