|
-
Mar 11th, 2001, 09:58 PM
#1
Thread Starter
Lively Member
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.
-
Mar 11th, 2001, 10:00 PM
#2
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
-
Mar 12th, 2001, 09:51 AM
#3
Frenzied Member
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
-
Mar 12th, 2001, 09:59 AM
#4
PowerPoster
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...)
-
Mar 12th, 2001, 11:14 AM
#5
Member
Use the WinSock SendData method with in the connect event.. this insures you have a connection.
-
Mar 12th, 2001, 11:26 AM
#6
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|