Home > Software engineering >  WinsockNet how to link two fixed IP to communicate with the machine
WinsockNet how to link two fixed IP to communicate with the machine

Time:09-27

 Public Function WinsockNet () 
Mainform. SysWinsock (0). Close
Mainform. SysWinsock (0). The RemoteHost=m_sWritingServerIP
Mainform. SysWinsock (0). The RemotePort=Val (m_sWritingServerPort)
Mainform. SysWinsock (0). The Connect
End the Function
The Public Function WinsockNet_2 ()
Mainform. SysWinsock (1). The Close
Mainform. SysWinsock (1). RemoteHost=m_sWritingServerIP_2
Mainform. SysWinsock (1). RemotePort=Val (m_sWritingServerPort_2)
Mainform. SysWinsock (1). The Connect
End the Function

I present links directly with the above two 2 IP
But the two IP can be connected, is not necessarily so I use the following code for reconnection
 If mainform. SysWinsock (0). The State & lt;> 7 Then 
Network interruption m_lpSysWarningTwo=m_lpSysWarningTwo Or MCA_DATASERVER_UNCONNECTED '
Call WinsockNet
End the if
If mainform. SysWinsock (1). The State & lt;> 7 Then
Network interruption m_lpSysWarningThree=m_lpSysWarningThree Or MCA_DATASERVER_UNCONNECTED_TWO '
Call WinsockNet_2
End the if

But now when I SysWinsock even (0), the received information is normal, but when I SysWinsock (1) even when not SysWinsock (0) receiving less than information
Could you tell me how to write this kind of situation the link of program

CodePudding user response:

TCP reconnection mechanism of the water is deep, deep,
Try every time before reconnection delay for 30 seconds,

How to delay the reference to the following:
http://bbs.csdn.net/topics/391882378
  • Related