Ok, this one is a little embarrassing, I can't seem to sort it out. I have found a lot of examples in forums about Winsock controls that won't connect, but strangely not in the very simple way it isn't connecting for me.
I have identical code to connect a Winsock object to a network in two applications. The first application is a simple demonstration program which just connects to the port and transmits and receives some data. Very simple. The second program is enormous and I am just adding the ability to talk to an Ethernet device instead of a COM port (it is a data-logging program for my company).
Here is the simple setup:
TCPClient.Close
TCPClient.RemoteHost = "192.168.0.24"
TCPClient.RemotePort = "10001"
TCPClient.Connect
If TCPClient.State = sckConnected Then
i = i 'never ends up here, even when I step through (in other words there has been time to connect, a delay)
Else
i = i 'always ends up here, and the state is always 6, connecting. However, in the demonstration program, the program always ends up here.
End If
When I step through in the demonstration program, the .State value is always 7 when I get to that line. However, in the giant logging program, even when I move these lines to the very first lines of the startup object, the .State value is always 6, or connecting. That said, somehow, when it is added to the communication routines, it does seem to connect and work most of the time. However, I need for it to work perfectly, and what I am observing is not perfect, and at times, not functional.
I have identical code to connect a Winsock object to a network in two applications. The first application is a simple demonstration program which just connects to the port and transmits and receives some data. Very simple. The second program is enormous and I am just adding the ability to talk to an Ethernet device instead of a COM port (it is a data-logging program for my company).
Here is the simple setup:
TCPClient.Close
TCPClient.RemoteHost = "192.168.0.24"
TCPClient.RemotePort = "10001"
TCPClient.Connect
If TCPClient.State = sckConnected Then
i = i 'never ends up here, even when I step through (in other words there has been time to connect, a delay)
Else
i = i 'always ends up here, and the state is always 6, connecting. However, in the demonstration program, the program always ends up here.
End If
When I step through in the demonstration program, the .State value is always 7 when I get to that line. However, in the giant logging program, even when I move these lines to the very first lines of the startup object, the .State value is always 6, or connecting. That said, somehow, when it is added to the communication routines, it does seem to connect and work most of the time. However, I need for it to work perfectly, and what I am observing is not perfect, and at times, not functional.