Udp client is not available from another application

I am trying to create a client server application in Java using UDP. The problem is when the client connects to the server, the server registers the client, and another application tries to use clientIP and clientPort to connect to the client; the client cannot receive any data.

I managed to recreate the DatagramSocket to connect to the client using its IP and port, but when this is done using another application, the connection is not reached.

I would like to mention that the port that I am listening to for the client on the server is different from the port that the server application uses.

How can we reach this message?

Please help me. Thanks.

+3
source share
2 answers

Your comment “when the client connects to the server” made me wonder if you used connect () for the DatagramSocket client. If so, do not call connect () on the socket. UDP is a connectionless protocol, and connect () is not required. By calling connect () on a UDP socket, the socket can only send / receive data to the host specified with connect ().

If this is not the case, then I can only think that some kind of firewall can be enabled on your client computer, or there is a NAT / Firewall between your client and server or other hosts. Check with Wireshark if your client is receiving any packages from another application.

Hope this helps.

+1
source

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


All Articles