Results 1 to 5 of 5

Thread: Winsock Confusion!

  1. #1
    nzer
    Guest
    Hi,

    Just started trying to make a simple messinging program in VB using winsock.. i really can't see what is going wrong!.. anyway.. i'll post up the code of the send program and the receive program.. maybe its really obvious hah i just don't see it!

    THE SENDER

    Option Explicit
    Dim strOutgoing As String
    Dim strIP As String


    Private Sub cmdSendMsg_Click()
    strIP = txtHostName.Text
    strOutgoing = txtMessage.Text
    winsock.RemoteHost = strIP
    winsock.RemotePort = 201
    winsock.Connect
    Do Until winsock.State = sckConnected
    DoEvents: DoEvents: DoEvents: DoEvents
    If winsock.State = sckError Then
    MsgBox "Problem connecting!"
    Exit Sub
    End If
    Loop

    winsock.SendData (strOutgoing)
    winsock.Close
    End Sub


    THE RECEIVER

    Private Sub Form_Load()
    winsock.LocalPort = 201
    winsock.Listen
    End Sub

    Private Sub winsock_ConnectionRequest(ByVal requestID As Long)
    If winsock.State <> sckClosed Then winsock.Close
    winsock.Accept requestID
    End Sub

    Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
    Dim strIncoming As String
    winsock.GetData strIncoming
    lblMessage.Caption = strIncoming
    End Sub


    Thanks for your help, i always get my error msg "Can't connect" so obviously something goes wrong :-(

  2. #2
    Banned
    Join Date
    Feb 2001
    Location
    Back to sh*tland
    Posts
    294
    Are the Sender program and receiver program in the same computer? If yes I think that's the problem.

  3. #3
    nzer
    Guest

    yep

    well yes they are.. but they should still work using 127.0.0.1 shouldn't they?

  4. #4
    Banned
    Join Date
    Feb 2001
    Location
    Back to sh*tland
    Posts
    294
    Well that I don't know. You would better try using two computers. I have downloaded once a vb project (here in vb world) that with a small change it would work with the same computer, but with me, it didn't work.

    It's rather confusing the stuff of dynamical IPs. Thanks to a vb project, the IP of my dad's computer is 127.0.0.1 ...

    Find a friend who is willing to try it with you. I think it's the best you can do

  5. #5
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: yep

    Originally posted by nzer
    well yes they are.. but they should still work using 127.0.0.1 shouldn't they?
    IP address 127.0.0.1 is called the loopback address. A loopback address is an address that tells the computer to test its own basic network setup. Data is passed within the local TCP/IP stack.

    My first question would be "Is the TCP/IP protocol installed on your PC"? If so, you can use 127.0.0.1 to test both the client and the server on your PC. I have done that my self even though I have static IP addresses on my PCs.

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