Package org.apache.commons.net.chargen

Examples of org.apache.commons.net.chargen.CharGenUDPClient


    public static final void chargenUDP(String host) throws IOException
    {
        int packets = 50;
        byte[] data;
        InetAddress address;
        CharGenUDPClient client;

        address = InetAddress.getByName(host);
        client = new CharGenUDPClient();

        client.open();
        // If we don't receive a return packet within 5 seconds, assume
        // the packet is lost.
        client.setSoTimeout(5000);

        while (packets-- > 0)
        {
            client.send(address);

            try
            {
                data = client.receive();
            }
            // Here we catch both SocketException and InterruptedIOException,
            // because even though the JDK 1.1 docs claim that
            // InterruptedIOException is thrown on a timeout, it seems
            // SocketException is also thrown.
            catch (SocketException e)
            {
                // We timed out and assume the packet is lost.
                System.err.println("SocketException: Timed out and dropped packet");
                continue;
            }
            catch (InterruptedIOException e)
            {
                // We timed out and assume the packet is lost.
                System.err.println(
                    "InterruptedIOException: Timed out and dropped packet");
                continue;
            }
            System.out.write(data);
            System.out.flush();
        }

        client.close();
    }
View Full Code Here


    public static final void chargenUDP(String host) throws IOException
    {
        int packets = 50;
        byte[] data;
        InetAddress address;
        CharGenUDPClient client;

        address = InetAddress.getByName(host);
        client = new CharGenUDPClient();

        client.open();
        // If we don't receive a return packet within 5 seconds, assume
        // the packet is lost.
        client.setSoTimeout(5000);

        while (packets-- > 0)
        {
            client.send(address);

            try
            {
                data = client.receive();
            }
            // Here we catch both SocketException and InterruptedIOException,
            // because even though the JDK 1.1 docs claim that
            // InterruptedIOException is thrown on a timeout, it seems
            // SocketException is also thrown.
            catch (SocketException e)
            {
                // We timed out and assume the packet is lost.
                System.err.println("SocketException: Timed out and dropped packet");
                continue;
            }
            catch (InterruptedIOException e)
            {
                // We timed out and assume the packet is lost.
                System.err.println(
                    "InterruptedIOException: Timed out and dropped packet");
                continue;
            }
            System.out.write(data);
            System.out.flush();
        }

        client.close();
    }
View Full Code Here

    public static final void chargenUDP(String host) throws IOException
    {
        int packets = 50;
        byte[] data;
        InetAddress address;
        CharGenUDPClient client;

        address = InetAddress.getByName(host);
        client = new CharGenUDPClient();

        client.open();
        // If we don't receive a return packet within 5 seconds, assume
        // the packet is lost.
        client.setSoTimeout(5000);

        while (packets-- > 0)
        {
            client.send(address);

            try
            {
                data = client.receive();
            }
            // Here we catch both SocketException and InterruptedIOException,
            // because even though the JDK 1.1 docs claim that
            // InterruptedIOException is thrown on a timeout, it seems
            // SocketException is also thrown.
            catch (SocketException e)
            {
                // We timed out and assume the packet is lost.
                System.err.println("SocketException: Timed out and dropped packet");
                continue;
            }
            catch (InterruptedIOException e)
            {
                // We timed out and assume the packet is lost.
                System.err.println(
                    "InterruptedIOException: Timed out and dropped packet");
                continue;
            }
            System.out.write(data);
            System.out.flush();
        }

        client.close();
    }
View Full Code Here

    public static final void chargenUDP(String host) throws IOException
    {
        int packets = 50;
        byte[] data;
        InetAddress address;
        CharGenUDPClient client;

        address = InetAddress.getByName(host);
        client = new CharGenUDPClient();

        client.open();
        // If we don't receive a return packet within 5 seconds, assume
        // the packet is lost.
        client.setSoTimeout(5000);

        while (packets-- > 0)
        {
            client.send(address);

            try
            {
                data = client.receive();
            }
            // Here we catch both SocketException and InterruptedIOException,
            // because even though the JDK 1.1 docs claim that
            // InterruptedIOException is thrown on a timeout, it seems
            // SocketException is also thrown.
            catch (SocketException e)
            {
                // We timed out and assume the packet is lost.
                System.err.println("SocketException: Timed out and dropped packet");
                continue;
            }
            catch (InterruptedIOException e)
            {
                // We timed out and assume the packet is lost.
                System.err.println(
                    "InterruptedIOException: Timed out and dropped packet");
                continue;
            }
            System.out.write(data);
            System.out.flush();
        }

        client.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.net.chargen.CharGenUDPClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.