From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ConnectToTCPServer is not returning an error

I'm using the ConnectToTCPServer function to try to connect to a TCP server, but when I change the port to something invalid, the function does not return an error. How can I poll the connection to determine whether I'm connected in a gracefull manner?

0 Kudos
Message 1 of 4
(3,736 Views)

Hi Steve_Block,

 

 

Just to clarify, the integer returned by ConnectToTCPServer is always a 0, even if you are supplying an invalid port number?

Tom D.
Staff Software Engineer
NI
0 Kudos
Message 2 of 4
(3,708 Views)

So how do I know the port is valid and the connection was successful?

 

0 Kudos
Message 3 of 4
(3,696 Views)

Hi Steve_Block,

 

ConnectToTCPServer should return a 0 if the port is valid and the connection was successful. Do you mean that the function is returning a 0 even if you are supplying it with a port number which you expect to be invalid?

 

What is the intended use of your application, and what port numbers are you using to test the function? After calling the function, assuming a connection is established, are you able to read from the server using ClientTCPRead?

Tom D.
Staff Software Engineer
NI
0 Kudos
Message 4 of 4
(3,656 Views)