I managed to install tcpdump on the router. I attached the output of command:
tcpdump -nnvvXSs dst 192.168.1.116 or src 192.168.1.116
/media/uploads/csorbag/wrt_packets.txt
I see the same as with wireshark on the server. Mbed sends only the first packet. So its clearly not reaching the router.
What I found strange in the dump is that after the first packet is sent mbed sends a DHCP Release message every time.
From that I figured out that the problem is after sending the second message I close the socket immediately. But it precedes the ACK packet for the first message and because the first has not been acknowledeged, the second is never sent and will be discarded forever because the socket is already closed when the ACK finally arrives.
By inserting a Thread::wait(1000) before closing the socket the server finally receives the second packet as well. I don't think it's normal, is it? I think Socket.close() should wait until there are no more unsent/unackknowledged/pending packets.
Inserting the wait() fixes the simplified test application, but it does not explain why my complex application fails. In that I never close the socket on client side first. That's the responsibility of the server. So I have to investigate the problem further.
It seems that one can only call send_all/send on a single TCPSocketConnection only once. The second time I send something it won't appear on network, endpoint won't receive it. See example below.