FAQ Database Discussion Community


UDP messaging service

java,sockets,udp,ip-address,datagram
I have to create a program that will send and receive messages to/from a remote IP address. So basically it should simulate a messaging service. In the program, you must enter the an IP address and the data will be sent to that specific address. Currently, I can send but...

Recombining several DatagramPackets into a single byte[]

java,udp,bytearray,datagram
Preface: I am NOT experienced at all and have likely made silly mistakes. Please correct these mistakes and teach me how to be better instead of berating me for being ignorant, if I wasn't already humbled by my lack of knowledge, I wouldn't need to ask for help. I have...

Can a received DatagramPacket be used to be sent again?

java,echo,datagram
I am testing a UDP echo server, is the following code correct? DatagramSocket s = ... DatagramPacket p = new DatagramPacket(new byte[512], 512); ... s.recieve(p); s.send(p); My question is, can I send the DatagramPacket just as I recieved it? According to the java specification, the contructor I used constructs a...

How to check if a response packet is received within a particular time limit?

java,timer,timertask,datagram
Suppose a client sends server a request. The server responds with an ACK. However, if the server does not respond within two seconds, the code terminates. socket.receive(ack); is a blocking call. However, I assumed that if I disconnected the socket in timer task, this blocking call will be ignored now...