I want to send data to server, then wait for an answer for one minute and then close the socket.
How to do it?
DatagramPacket sendpack = new ......;
socket.send(pack);
DatagramPacket recievepack = new .....;
//wait 1 minute{
socket.recieve(buf);
//wait 1 minute}
socket.close();
You can try this. Change the timeout of the socket as required in your scenario! This code will send a message and then wait to receive messages until the timeout is reached!