Results 1 to 7 of 7

Thread: Winsock

  1. #1
    Guest

    Question

    Hi there.

    I want to connect two or more computer using server/cliente method i want to use also winsock but i donīt have any code do do that, where can i get the code for the server and the client, thank you.

    numibesi

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    This will help you learn winsock: http://www.vbsquare.com/articles/comms/
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Guest

    Unhappy Something else, please

    Tx for the link but i tried and i keep getting lots of errors, so i tried to download the demo but some files are missing so i stuck again. Any idea.

    numibesi

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    If you will tell us what errors you are getting, that would help us to figure out what is wrong.

  5. #5
    Guest

    Angry See the text

    Server

    Code:
    Private Sub Form_Load()
        Winsock1.Protocol = sckTCPProtocol
        Winsock1.LocalPort = 1212
        Winsock1.Listen
    End Sub
    
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    Dim strData As String
        Winsock1.SendData "Hello From Server" 'the prob is here
        Text1.Text = Text1.Text & strData
    End Sub
    
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim strData As String
        Winsock1.GetData strData, vbString
        Text1.Text = Text1.Text & strDataIP
    End Sub
    Client

    Code:
    Private Sub Command1_Click()
        Winsock1.SendData "Client here!"
    End Sub
    
    Private Sub Form_Load()
        IP = "127.0.0.1"
        Port = "1212"
        Winsock1.Protocol = sckTCPProtocol
        Winsock1.Connect IP, Port
    End Sub
    
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Text1 = Text1 & bytesTotal
    End Sub
    The prob is on the server when i try to connect it says wrong prtocol etc.

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Code:
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    Dim strData As String
        Winsock1.SendData "Hello From Server" 'the prob is here
        Text1.Text = Text1.Text & strData
    End Sub
    Change it to:

    Code:
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    Dim strData As String
        Winsock1.Close
        Winsock1.Accept requestID
        Winsock1.SendData "Hello From Server" 
        Text1.Text = Text1.Text & strData
    End Sub
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  7. #7
    Guest

    Angry one part done

    That part now works but when i try to do this:

    Code:
    Private Sub Command1_Click()
        Winsock1.SendData "Still connected"    
    End Sub
    it gives me the same error wrong protocol......

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