The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.net  [27 examples] > Datagram  [2 examples]

e151. Sending a Datagram

    public static void send(InetAddress dst, int port, byte[] outbuf, int len) {
        try {
            DatagramPacket request = new DatagramPacket(outbuf, len, dst, port);
            DatagramSocket socket = new DatagramSocket();
            socket.send(request);
        } catch (SocketException e) {
        } catch (IOException e) {
        }
    }

 Related Examples
e152. Receiving a Datagram

See also: Encodings    HTTP    Hostnames and IP Addresses    Multicast    Sockets    URLs   


© 2002 Addison-Wesley.