Results 1 to 4 of 4

Thread: Please help me with this very simple winsock problem!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    18

    Please help me with this very simple winsock problem!!

    Hi,

    I need to build a very simple application. What is required to test both the client and server applications on the same PC? I am running Windows XP with Visual Basic 6 SP 6.

    The code for the simple client and server programs is as follows, but for some reason I get the error: runtime error 40006: wrong protocol or connection state for the requested transaction or request.

    The code:

    The Server app:

    Private Sub Form_Load()
    Winsock1.LocalPort = 1000
    Form1.Caption = Winsock1.LocalIP
    Winsock1.Listen


    End Sub

    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    If Winsock1.State <> sckClosed Then
    Winsock1.Close
    Winsock.Accept requestID
    End If
    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)


    Winsock1.GetData strData, vbString
    Form1.Print strData

    End Sub

    The client app:

    Private Sub cmdSendhello_Click()


    Winsock1.SendData "hello"




    End Sub

    Private Sub Command1_Click()
    Winsock1.RemotePort = 1000
    Winsock1.RemoteHost = "192.168.1.3"

    Winsock1.Connect
    End Sub

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    18

    Re: Please help me with this very simple winsock problem!!

    no need, i figured it, I replaced the IP with the machine name and it worked

  3. #3
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475

    Re: Please help me with this very simple winsock problem!!

    If your testing it on the same computer, you can use your loopback IP which is 127.0.0.1 as the remote host.
    If my post was helpful please rate it

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Please help me with this very simple winsock problem!!

    Or just:
    VB Code:
    1. .RemoteHost = localhost


    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

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