Re: java socket programming doubt
On May 19, 2:42 pm, sam.bark...@gmail.com wrote:
Hi All,
I am trying to create a udp socket.
It works fine but the program hhangs for a few seconds[at
DatagramSocket clientSocket = new DatagramSocket();] before ti
actually sends the data out.Could any one tell me why?
try
{
System.out.println("Creating datagram");
DatagramSocket clientSocket = new DatagramSocket();
InetAddress IPAddress =
InetAddress.getByName("localhost");
byte[] sendData;
byte[] receiveData = new byte[1024];
String sentence ="TEST";
sendData = sentence.getBytes();
DatagramPacket sendPacket =
new DatagramPacket(sendData, sendData.length,
IPAddress, 9876);
clientSocket.send(sendPacket);
}
Cheers,
Sam
It doe NOT [your code copied into main] for me. So check the rest of
your code...
BTW: why do you think that it hangs there? (and NOT somewhere else)?