Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

winsock control

Status
Not open for further replies.

99mel

Programmer
Oct 18, 1999
379
GB
I'm havin a problem with the winsock control. I reckon this is a long shot but someone might be able to help me!

I'm connected through winsock 6.0 to a third party program. I connect to it by using the winsock1.connect [remote host] [remote port], this code is in a buttons click procedure. I have another button which fires of the winsock1.senddata command. This all works fine and the thirdparty software receives the data and works as it should.

However! if i plonk the senddata winsock command in to the same click procedure of the connection command i get the error 'Wrong protocol or connection state for the requested transaction or request'

After the connect is fired off i print off the state of the winsock and its 6 and IS connected to the thirdparty software.

I've tried sleep commands and all sorts but i just get that error when i have both commands in the same procedure!

any helpp appreciated!
 
how about:

sub command1_click()

'connection code
'
'
call command2_click()

end sub
 
was really wanting to find out why it was doing that.
 
It's doing that because you are not actually connected yet.

Put your send in the connect event if you feel you must do it with one click, or, dont require a click to do the connect. Do the connect on a timer after your form loads, so you're already connected when the send button gets clicked.

Tuna - It's fat free until you add the Mayo!
 
the state property after the connect says it is connected though.

I will be simply doing all this in a module with no user intervention required at all! The click procedures was just testing it to get it working.
 
Then you MUST test for the connection state prior to doing the send.

private sub winsock1_Connect() will fire or you can do this:

private sub timer1_timer()
timer1.enabled = false
if winsock1.state = sckConnected then
'call your send data here
end if
timer1.enabled = True
end sub
Tuna - It's fat free until you add the Mayo!
 
Oh, one other thing... once the send does take place, disable the timer or you'll be repeating that send. my bad.

Tuna - It's fat free until you add the Mayo!
 
cheers will try that.

i'm thinking the sckconnected may work as i just see the value '6' at the moment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top