I'm using the DatagramSocket
class in Java to receive udp packets from a client written in C. Here is the code that receives (the server socket is already set up):
byte[] inputByte = new byte[1];
DatagramPacket recvdPacket = new DatagramPacket(inputByte, inputByte.length);
try {
serverSocket.receive(recvdPacket);
And then it prints the contents. My debugging messages (not shown in this code) indicate that it's successfully getting to the receive()
part and is waiting (it's a blocking call). Here is the problem:
This server only receives packets the second time the client sending the messages is run, never the first. Even if the client sends multiple packets the first run, the server never shows anything until the second time the entire client is run. Is it safe to assume the problem is in the server side, not the client side? (the client side code was not written by me...it's disgusting, and in C).