Asyncronous socket does not accept more then one connection

N

Nikolay Petrov

Code:
\\\\\\\\
Private Sub ConnectionsListener()
_acceptCallBack = New AsyncCallback(AddressOf acceptHandler)
'Dim listenSocket As Socket
Try
_listenSocket = New Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp)
_listenSocket.Bind(New System.Net.IPEndPoint(IPAddress.Any,
Me._ApplicationPort))
_listenSocket.Listen(-1)
_listenSocket.BeginAccept(_acceptCallBack, _listenSocket)
Catch ex As Exception
msgbox(ex.tostring)
End Try
End Sub
////////


I run this as separate thread, but it only accepts first connection.

what is wrong?

tnx
 
S

Shane

_listenSocket.BeginAccept(_acceptCallBack, _listenSocket)

I run this as separate thread, but it only accepts first connection.

what is wrong?

You need to accept the connection on another socket handle. Use
_listenSocket to listen, then an array of connectionSockets to handle
the connection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top