Results 1 to 6 of 6

Thread: WinSock Error

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    82

    Exclamation

    I am trying to learn how to use WinSock. Logically I think it is easy, you just need to set up the ports and the rest and things should work (right?)

    Anyway, I send a message through a port, I get this message (Run-time error 40006 'Wrong protocol or connection state for the requested transaction or request'. What does this mean? Please help!

    Something on the side:
    I'm trying to use this instead of DCOM, if you could give a hand with DCOM, I would gladly accept. Thanks.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    did you set the protocol property? it must be set to either UDP or TCP in order to work...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    If you are using the correct protocol then you are most likely sending data before the connection has completed. Check the control's .State property before envoking the .SendData method. .State should be = sckConnected = 7

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    It does not related to the protocol used. In Winsock this error normally mean your port is either closed or your have't initialize (Open) the port when you try to send something out from the port.

    So you should check the state before you send anything out.

    Code:
        If Winsock1.State = sckConnected Then
            Winsock1.SendData "Testing..."
        Else
            MsgBox "Invalid winsock state!"
        End If
    
    'Code improved by vBulletin Tool (Save as...)

  5. #5
    Member
    Join Date
    Mar 2001
    Posts
    34
    Use the WinSock SendData method with in the connect event.. this insures you have a connection.

  6. #6
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    Originally posted by symac2001
    Use the WinSock SendData method with in the connect event.. this insures you have a connection.
    That's fine if you want to send 1 message and be done with it.

    If you need to exchange multiple messages, you want to establish a persistant connection. That means the SendData should be elsewhere so that you can call it when you need to send a message. The State should be checked before each call to make certain that the connection is still up.

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