Address already in use: I misunderstand UDP

Is it possible for two or more programs to control UDP packets on the same port? We have a device that converts RS-232 data to UDP on port 55110, but it seems that I can only have one listener working on this computer. Trying the second reason "Address is already in use." Apparently, there is some other program on the computer, because REUSE => 1 does not help. Several users would like to try the data. We apologize for such a simple question.

+3
source share
3 answers

It is possible that two programs are listening on the same UDP port, but both programs must indicate that they want to allow port sharing. Here is an excerpt from my code that tells the OS to do this (called just before calling bind () in UDP juice):

if (allowShared)
{
   const int trueValue = 1;
   setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &trueValue, sizeof(trueValue));
#ifdef __APPLE__   // MacOS/X requires an additional call also
   setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &trueValue, sizeof(trueValue));
#endif
}
+3
source

udp_reflector is a simple, open source tool to work around the "Address already in use" problem when working with udp data.

http://code.google.com/p/udp-reflector/

+1
source

, , UDP-, Steve-o, . , .

- 55110, , .

0

Source: https://habr.com/ru/post/1787077/


All Articles