Results 1 to 2 of 2

Thread: 40020 Error after connect

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    1

    40020 Error after connect

    Hello
    I have a little problem. I lear VBscript and i made two applications wchich connect and get data Here is Codes

    Code:
    Server
    Private Sub Form_Load()
    Winsock1.LocalPort = 15778
    Winsock2.LocalPort = 15779
    Winsock1.Listen
    Winsock2.Listen
    End Sub
    
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    Winsock1.Accept requestID
    End Sub
    Private Sub Winsock2_ConnectionRequest(ByVal requestID As Long)
    Winsock2.Accept requestID
    End Sub
    
    Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
    Dim data As String
    Winsock2.GetData data
    Label1.Caption = data
    End Sub
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim data As String
    Winsock1.GetData data
    Label2.Caption = data
    End Sub
    Code:
    Client
    
    Private Sub Form_Load()
    Dim data As String
    data = "testowe dane"
    Winsock1.Connect
    If Winsock1.State = 7 Then
    Winsock1.SendData data
    Else
    Label1.Caption = "Brak połączenia"
    End If
    End Sub
    Client application shoul connect and send data. Server application should listed,get and show data. When i run server isnt any error but when i run client application i get 40020 error on server. Could someone tell me why ?

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: 40020 Error after connect

    You can't accept a request with an open socket. You must close it first.eg
    Code:
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    Winsock1.Close
    Winsock1.Accept requestID
    End Sub

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