By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,184 Members | 1,500 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,184 IT Pros & Developers. It's quick & easy.

Socket.Listen(maxConn) dont work

P: n/a
I have a Socket server.
Any value I give to the listener.Listen(1) socket, seems that it accept any
connection request... why's that?
I set a sleep on send thread in order to delay the response and I made
another few requests from differend browsers...all requests was accepted and
then the threads resumed, browser received data

I have the below function that start the server listening:

Private Sub StartListening()
Dim localEndPoint As IPEndPoint = setUpSocketServer()
Dim listener As New Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp) ' Intializes a TCP/IP socket.
cancelServer = False
listener.Bind(localEndPoint) ' Bind the socket to the local
endpoint and listen for incoming connections.
While True
If cancelServer Then
' listener = Nothing
Catch e As Exception
End Try
Exit While
End If
allDone.Reset() ' Set the event to
nonsignaled state.
listener.BeginAccept(New AsyncCallback(AddressOf
AcceptCallback), listener) ' Start an asynchronous socket to listen for
RaiseEvent ServerStarted(gameName)
'outputConsole.Text = "Waiting for connections ..." +
ControlChars.CrLf + outputConsole.Text
allDone.WaitOne() ' Wait until a connection is made before
End While
Catch e As Exception
RaiseEvent StatusChanged("Server start failed -- Reason: " +
End Try
RaiseEvent ServerClosed()
End Sub 'StartListening
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.