NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem creating UDP sockets over the loopback network interface

Hello,

I have a simple C++ program that interacts with a LabVIEW RT program in a CRIO 9068. The C++ code acts as a UDP server that receives data from the LabVIEW RT program on a specific port (e.g. 32000) over the loopback interface. The UDP server is "bind" to the port. When i cross-compile and run the C++ program, i noticed that the binding fails and thus the two programs could not communicate. This happens when the communication is made over the loopback interface. Otherwise, creating UDP sockets between a CRIO 9068 and another machine works fine. I verified this restriction by writing simple UDP server and client programs in C++ that communicate over the loopback interface. While these simple programs fail to communicate in CRIO 90868 Linux RT, they successfully communicate in other platforms (e.g Ubuntu).

Is this restriction on creating UDP sockets over the loopback interface purposely introduced for security reasons or have I failed to notice something else? How do I get around this restriction and make my C++ program talk to the LabVIEW RT program over the loopback interface?

Thanks!

T

0 Kudos
Message 1 of 4
(6,281 Views)

ttesfay,

When you say the loopback interface, are you connecting to localhost and letting the local DNS entry resolve, or connecting to 127.0.0.1?

Can you try and connect via the eth0 address to see if it works? (this will help deturmine if it is specificly to the loopback interface or if it is something else).

-TD

Message 2 of 4
(5,038 Views)

Hello tduffy,
Thank you for your reply. I just found out that the problem happened because the LabVIEW RT program and the receiver C++ program were trying to use the same port number - that is why the bind failed. The LabVIEW RT implementation is not mine and i did not know that it was implemented such that both sender and receiver port numbers are the same. This is not a problem when the receiver runs in another machine. The problem manifested when I tried to run my code in the same Crio 9068 machine that runs the LabVIEW RT.

Thanks again,

T

0 Kudos
Message 3 of 4
(5,038 Views)

Ahh, good catch!  Glad you figured it out!

-TD

0 Kudos
Message 4 of 4
(5,038 Views)