Winsock for VB6

  1. #1
    Marios's Mustache Wax Reputation: 10

    Join Date
    Sep 2006
    Posts
    2
    Rep Power
    0

    Question Winsock for VB6

    hello.

    I am an alright VB6 programmer, and would like to learn how to use winsock and comunicate with other computers via an IP adress.

    Thanks,

    VB_Programmer_Person

  2. #2
    Luigiís Pizza Reputation: 10

    Join Date
    Jul 2006
    Posts
    145
    Rep Power
    9

    Default

    you need to look up a guide..

    more less you have the server listen... then you have the client connect

    after that you send and receive the data and interpret it

    like I said look up a guide

  3. #3
    Marios's Mustache Wax Reputation: 10

    Join Date
    Sep 2006
    Posts
    2
    Rep Power
    0

    Default

    yeah, I found a few, but I still don't quite get it - can someone tell me whats wrong with this code?:

    Private Sub Command1_Click()
    Winsock1.SendData "Text1.Text"
    End Sub

    Private Sub Form_Load()
    Winsock2.Listen

    Winsock1.Connect Text3.Text, 1234
    End Sub

    Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
    Winsock2.GetData Text2.Text
    End Sub

  4. #4
    Luigiís Pizza Reputation: 10

    Join Date
    Jul 2006
    Posts
    145
    Rep Power
    9

    Default

    Quote Originally Posted by VB_Programmer_Person View Post
    yeah, I found a few, but I still don't quite get it - can someone tell me whats wrong with this code?:

    Private Sub Command1_Click()
    Winsock1.SendData "Text1.Text"
    End Sub

    Private Sub Form_Load()
    Winsock2.Listen

    Winsock1.Connect Text3.Text, 1234
    End Sub

    Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
    Winsock2.GetData Text2.Text
    End Sub
    wait do you have the server and client stuff altogether? whats the point of that theres no need to connect then lol.

    Anyways split them up. And Winsock doesnt need 2 different names... you can have it the same throughout. I will give you basic code to connect to 1 client to 1 server.


    CLIENT

    Private Sub cmdConnect_Click()
    Winsock.RemoteHost = "127.0.0.1" ' this is the Ip of the server 127.0.0.1 loops back to your own computer
    Winsock.RemotePort = 8765 ' this is the port it must be the same as the server
    Winsock.Connect ' connect!
    End Sub

    Private Sub cmdSend_click()
    Winsock.SendData Text1.Text ' sends the data in the textbox
    End Sub

    Private Sub winsock_DataArrival(ByVal bytesTotal As Long)

    Dim incomingData As String 'this stores the data we receive

    Winsock.GetData incomingData ' this stores the data in the variable we set above
    End Sub

    I will do server later I gotta go take a stat test here like right now.

  5. #5
    Marios's Mustache Wax Reputation: 10

    Join Date
    Sep 2006
    Posts
    18
    Rep Power
    9

    Default

    Better to make your connection input~

    port = inputbox("Enter port name here")
    host = inputbox("Enter host ip here")
    winsock1.connect host, port

    Same with the server hosting
    port = inputbox("Enter port to host on")
    winsock1.localport = port
    winsock1.listen

    And another thing which is quite useful
    Ina cmd click put this~
    msgbox "Your ip address is " & winsock1.localip
    or something along those lines

Posting Permissions

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