Results 1 to 2 of 2

Thread: Server will not connect to client - Winsock Error 0?!!

  1. #1

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692

    Server will not connect to client - Winsock Error 0?!!

    I am having a problem here.

    I have a server program set up to connect to its client as soon as the client connects. The client connects fine, but apparently the server listener's Connect event isn't firing, because I'm not getting a message on the client saying we're connected. I paused the program, and did a wskServerListener.State check, and it was in error. I checked what the error number was, and it says Error 0, and will not give me an error description. Take the error handler out, and I get the error "Invalid operation for current state, and wskServerListener still reports that it's in error.

    This is the code that connects to the client as soon as the client connects to the server.

    VB Code:
    1. Private Sub wskServerListener_ConnectionRequest(ByVal requestID As Long)
    2.     wskServerListener.Close
    3.     wskServerListener.Accept requestID
    4.     rtbServerMessages.Text = rtbServerMessages.Text & "A client has connected" & vbNewLine
    5.     ColorServerMessageLines
    6.     If Not wskServerConnector.State = sckConnected Then
    7.         wskServerConnector.Connect wskServerListener.RemoteHostIP, 350
    8.     End If
    9. End Sub

    This is the code that handles the connection request to the client.

    VB Code:
    1. Private Sub wskClientListener_ConnectionRequest(ByVal requestID As Long)
    2.     wskClientConnector.Close
    3.     wskClientConnector.Accept requestID
    4. End Sub

    And as you can see from this code, I do have it set to listen on the correct port, 350.

    VB Code:
    1. Private Sub wskClientConnector_SendComplete()
    2.     If Not wskClientListener.State = sckListening Then
    3.         wskClientListener.LocalPort = 350
    4.         wskClientListener.Listen
    5.     End If
    6. End Sub

    Upon connection, the client sends your username to the server for identification like this.

    VB Code:
    1. Private Sub wskClientConnector_Connect()
    2.     wskClientConnector.SendData "USER " & txtUsername.Text
    3. End Sub
    Last edited by hothead; Mar 6th, 2004 at 07:10 AM.

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    You have the whole thing wrong... client and server...
    Take a look at the chat program I made in this thread
    http://www.vbforums.com/showthread.p...0&pagenumber=2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width