Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asynch Socket Listener.

Status
Not open for further replies.

joejack0330

Technical User
Jan 27, 2006
95
0
0
US
Hi, having an issue with our socket hanging every once in a while. This link is the closest that I found to our problem but not sure how implement the solution suggest about put code in new function and start a new thread? We basically use the same example that they have link to from Microsoft's site. Does anyone have an example doing what is mentioned here or any other ideas? Thanks, Joe
 
Not sure but from what they said try something like this.

Code:
    Private Sub listen_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listen_btn.Click
        Dim ListenThread As New System.Threading.Thread(AddressOf StartListen)
        ListenThread.Start()
    End Sub

    Private Sub StartListen()
        While True
            ' Set the event to nonsignaled state.
            allDone.Reset()

            ' Start an asynchronous socket to listen for connections.

            listener.BeginAccept(New AsyncCallback(AddressOf AcceptCallback), listener)

            ' Wait until a connection is made and processed before continuing.

            allDone.WaitOne()
        End While
    End Sub

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top