Home > Net >  The SOCKET connection timeout problems
The SOCKET connection timeout problems

Time:11-13

Consult everybody:
I made a TCP client computer, connect several devices, take off a connection, start another connection, to read and write data, sometimes a device will be broken network,
Its connection time will have more than ten seconds, this time can be set up, is made very quickly to the next device access,
Label13. Text="is connect... "

Socket1=Nothing
Socket1=New Socket (AddressFamily. InterNetwork, SocketType Stream, ProtocolType. Tcp)
While True
Try
Socket1. Connect (localEndPoint (I))
GoTo Connected
Catch the ex As Exception
MsgBox (" ERROR ")
End the Try
End While

Connected:

ReDim DataBytesRec1 (Socket1 ReceiveBufferSize)
ThreadSocketRec1=New Thread (AddressOf SocketReciveData1)
ThreadSocketRec1. IsBackground=True
ThreadSocketRec1. Start (Socket1)

CodePudding user response:

https://blog.csdn.net/kucoffee12/article/details/86308178

CodePudding user response:

But, over time, I will try again to connect, then will pop up "on the same socket is another asynchronous operation, can't call BeginConnect," is what I found on the device even don't, I would have to connect other devices, can appear alarm, that is to say BeginConnect can be forced to end, so to launch a connection,
  • Related