Results 1 to 7 of 7

Thread: Trouble with WinSock SendData method!!

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    London, ON
    Posts
    40

    Angry

    I ahve recently been acquainting myself with the WinSock control. I have used the tutorial from http://www.vbweb.co.uk\controls\win_sock.htm to create a WinSock program that uses TCP/IP protocol to communicate between two forms on the same computer. It works. When I tried similar code but instead having the RemoteHost property set to another computer the SendData method gives me a Run-Time Error # 40006. One thing I did notice is that on the project that works WinSock.State = 7 and on the one that doesn't WinSock.State = 9. I'm pretty sure that the errors lies there because there is no error after the Connect Method. Please give an help you can. If you have any idea or just shoot off a few ideas you might reach me on ICQ, nick name = Captain Pinko.

    thnx
    Visual Basic 6 Professional Edition
    Captain Pinko

    also:
    Turbo Pascal, Turing, QBasic

  2. #2
    Guest
    7 = sckConnected
    9 = sckError
    Error 40006 = sckBadstate
    sckBadState, Wrong protocol or connection state for the requested transaction or request.

    You are probably trying to send data or getdata while you are not (yet) connected to the other machine(Connecting to antoher machine goes way slower then connecting to your own), wich would be right because you got an error (state = 9)


    Look what the Winsock_Error event returns (it should give some sort of error)


    Hope it helps,

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    London, ON
    Posts
    40

    Unhappy Okay...

    Then how do I know if I am connected with the other
    computer. I always figured it was pretty much instantaneous.
    How long should it take? What should I do? Does anybody know what all the state constants mean\are? Please post...
    Visual Basic 6 Professional Edition
    Captain Pinko

    also:
    Turbo Pascal, Turing, QBasic

  4. #4
    Guest
    Example:
    Code:
    Private Sub Command1_Click()
        'Connect
        Winsock1.Connect "127.0.0.1", 9876
        
        'Wait
        Do Until Winsock1.State <> sckConnecting
            DoEvents
        Loop
        'Are we connected
        If Winsock1.State = sckConnected Then
            'Yes we are
            Winsock1.SendData "MyData" & vbCrLf
        Else
            'Nope we aint
        End If
        
    End Sub

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    London, ON
    Posts
    40

    Do you know what all the constants mean?

    Do you know what all the winsock state constants are?
    Visual Basic 6 Professional Edition
    Captain Pinko

    also:
    Turbo Pascal, Turing, QBasic

  6. #6
    Guest
    yes indeedy!

    Code:
    Constant              Value       Description 
    
    sckClosed             0           Default.  Closed 
    sckOpen               1           Open 
    sckListening          2           Listening 
    sckConnectionPending  3           Connection pending 
    sckResolvingHost      4           Resolving host 
    sckHostResolved       5           Host resolved 
    sckConnecting         6           Connecting 
    sckConnected          7           Connected 
    sckClosing            8           Peer is closing the connection 
    sckError              9           Error

  7. #7
    New Member
    Join Date
    Sep 2000
    Location
    UK
    Posts
    4

    Updated Link

    Just a note to say that the tutorial mentioned @ vbweb has been moved to

    http://www.vbweb.co.uk/show/78/

    go visit Developer Fusion!!

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