DatagramSocket waitForNextConnection never returns


#1

One process does:

DatagramSocket socket (9666, false);
DatagramSocket *newSocket = socket.waitForNextConnection ();

if (newSocket)
{
  _DBG ("COnnected");

}

The other one does:

String message ("MESSAGE TO SEND");
DatagramSocket socket (0);

socket.connect (destHost->getText(), destPort->getText().getIntValue());

if (socket.isConnected())
{
      socket.write ((void *)message.toRawUTF8(), message.getNumBytesAsUTF8() + 1);
}

The server part never finished, i can see when doing strace() on the process that the messages are getting through:

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
bind(6, {sa_family=AF_INET, sin_port=htons(9666), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
select(7, [6], NULL, NULL, NULL)        = 1 (in [6])
getsockopt(6, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(6, "", 0, 0, {sa_family=AF_INET, sin_port=htons(41161), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
select(7, [6], NULL, NULL, NULL)        = 1 (in [6])
getsockopt(6, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(6, "", 0, 0, {sa_family=AF_INET, sin_port=htons(50030), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
select(7, [6], NULL, NULL, NULL)        = 1 (in [6])
getsockopt(6, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(6, "", 0, 0, {sa_family=AF_INET, sin_port=htons(39825), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
select(7, [6], NULL, NULL, NULL)        = 1 (in [6])
getsockopt(6, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(6, "", 0, 0, {sa_family=AF_INET, sin_port=htons(58723), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
select(7, [6], NULL, NULL, NULL)        = 1 (in [6])
getsockopt(6, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(6, "", 0, 0, {sa_family=AF_INET, sin_port=htons(45439), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
select(7, [6], NULL, NULL, NULL)        = 1 (in [6])
getsockopt(6, SOL_SOCKET, SO_ERROR, [0], [4]) = 0

But the method waitForNextConnectionIO never returns so i can't handle the new connection (piece of data since UDP is not connection based)


#2

I noticed that doing waitUntilRead() works at least on Windows (i use a seperate thread), and just read on the socket once the data arrives.

I noticed there is no isBound() method, that could be useful to see if we need to bind the socket again (similar to isConnected)

 

UDP i much better for streaming live data that i need right now, maybe it could be possible to do a subclass of the InterprocessConnectionServer based on UDP ?