Java Code Examples for java.net.DatagramSocket#isBound()

The following examples show how to use java.net.DatagramSocket#isBound() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReuseAddressTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
String getInfo(DatagramSocket soc) {
    if (soc == null) {
        return null;
    }

    return "localPort: " + soc.getLocalPort()
            + "; localAddress: " + soc.getLocalAddress()
            + "; remotePort: " + soc.getPort()
            + "; remoteAddress: " + soc.getInetAddress()
            + "; isClosed: " + soc.isClosed()
            + "; isBound: " + soc.isBound();
}
 
Example 2
Source File: UDPTransport.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
public UDPTransport(DatagramSocket socket, int mtu)
    throws IOException
{
    if (!socket.isBound() || !socket.isConnected())
    {
        throw new IllegalArgumentException("'socket' must be bound and connected");
    }

    this.socket = socket;

    // NOTE: As of JDK 1.6, can use NetworkInterface.getMTU

    this.receiveLimit = mtu - MIN_IP_OVERHEAD - UDP_OVERHEAD;
    this.sendLimit = mtu - MAX_IP_OVERHEAD - UDP_OVERHEAD;
}
 
Example 3
Source File: UDPTransport.java    From ripple-lib-java with ISC License 5 votes vote down vote up
public UDPTransport(DatagramSocket socket, int mtu)
    throws IOException
{
    if (!socket.isBound() || !socket.isConnected())
    {
        throw new IllegalArgumentException("'socket' must be bound and connected");
    }

    this.socket = socket;

    // NOTE: As of JDK 1.6, can use NetworkInterface.getMTU

    this.receiveLimit = mtu - MIN_IP_OVERHEAD - UDP_OVERHEAD;
    this.sendLimit = mtu - MAX_IP_OVERHEAD - UDP_OVERHEAD;
}