Results 1 to 1 of 1
Thread: An echo server using UDP sockets
-
An echo server using UDP sockets
This Java tip shows how to create an echo server using UDP sockets.
Java Code:import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.SocketException; public class UdpEchoServer { static final int BUFFERSIZE = 256; public static void main(String[] args) { DatagramSocket sock; DatagramPacket pack = new DatagramPacket(new byte[BUFFERSIZE], BUFFERSIZE); try { sock = new DatagramSocket(7); } catch (SocketException e) { System.out.println(e); return; } // echo back everything while (true) { try { sock.receive(pack); sock.send(pack); } catch (IOException ioe) { System.out.println(ioe); } } } }
Similar Threads
-
Sending Mail Using Sockets
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:05 PM -
how to send files through sockets
By gabriel in forum Advanced JavaReplies: 3Last Post: 01-12-2008, 08:10 AM -
echo of pwd
By jeffpoulsen in forum New To JavaReplies: 3Last Post: 12-04-2007, 03:14 PM -
Help with Sockets
By Eric in forum NetworkingReplies: 3Last Post: 12-01-2007, 08:09 PM -
Problems sending file throught TCP sockets
By Nite in forum Advanced JavaReplies: 2Last Post: 08-04-2007, 09:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks