Showing results for 
Search instead for 
Did you mean: 

TCP/IP sending and receiving messages on one port?

Go to solution

I am a new Labview user (I'm working on Labview 2019) and forgive me, please, if I ask in a wrong way.
I'm working on a project, where I send and receive data from server using tcp/ip communication. It's necessary, that these two operations are on one port. When I have two different ports, there is no problem but when I use only one the same port, only one operation is executed (error 56).

The program is working as follows:

A message (sent by plc and converted in labview) is send to server. Then server answers, so labview is listening. The received message is converted in labview and then transfered to plc.

I am attaching a part of my labview program. Do you have some ideas, how to send and receive data using one port? Screenshot_1.png


0 Kudos
Message 1 of 3
Accepted by topic author anna172

Your misunderstanding something here. The port number you pass to the TCP Open Connection specifies the remote port to which you want to send the message and the port number on TCP Listen specifies the local port on which the socket is listening for incoming connection requests. They can absolutely contain the same number since they refer to two different endpoints unless of course your server is also installed on the same computer. If that is the case the setup is fundamentally flawed if it wants you to use the same port number for both connections. That simply can't work as a port number can only be opened on any machine (a specific IP address) exactly once.  

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 3

Thank you for your help! Server isn't on the same computer. PC with labview is only tool used to communication between server and PLC driver. I don't have access to the real server yet. I'm using only simulator. That's why I had everything on one computer. Using the second has solved the problem.  Thank you !

0 Kudos
Message 3 of 3