ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   mswinsck.ocx (https://www.excelbanter.com/excel-programming/308334-re-mswinsck-ocx.html)

Eusch

mswinsck.ocx
 
When you call senddata and you single step there is a lot of time (in
processor terms) between the call to connect and senddata. When you reached
senddata, the underlying socket had a chance to connect. However if run full
throttle the underlying socket is not yet connected. You might wan't to add
this before the call to send data:

' wait for connection
While winsock.state < sckConnected
Wend

Hope this helps.

"Fung" wrote:

Hello

I use the following codes to pass a socket message to another server.
It works in the debug mode when I execute it step by step using F8.
However, it returns error when I execute it by pressing F5 or by clicking CommandButton1.
The error is: [40006] Wrong protocol or connection state for the requested transaction or request.
Any idea about this?

Private WinSock As Object
Private Sub CommandButton1_Click()
Set WinSock = New MSWinsockLib.WinSock

With Winsock
.Protocol = sckTCPProtocol
.RemoteHost = "server1-2000"
.RemotePort = 690
.Connect
End With

Winsock.SendData strMessage
End Sub



All times are GMT +1. The time now is 02:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com