Example usage for java.net DatagramSocket isConnected

List of usage examples for java.net DatagramSocket isConnected

Introduction

In this page you can find the example usage for java.net DatagramSocket isConnected.

Prototype

public boolean isConnected() 

Source Link

Document

Returns the connection state of the socket.

Usage

From source file:Main.java

public static void main(String args[]) {
    try {//from   w w w . j  a v  a 2 s  .  co m

        InetAddress ia = InetAddress.getByName("www.java2s.com");

        DatagramSocket ds = new DatagramSocket();

        byte buffer[] = "hello".getBytes();
        DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, 80);

        ds.send(dp);
        System.out.println(ds.isConnected());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.googlecode.jmxtrans.connections.DatagramSocketFactory.java

/**
 * Validates that the socket is good.// w  ww  . j av a2 s  .c o  m
 */
@Override
public boolean validateObject(SocketAddress key, DatagramSocket socket) {
    return socket.isBound() && !socket.isClosed() && socket.isConnected();
}

From source file:com.bitbreeds.webrtc.dtls.DtlsMuxStunTransport.java

public DtlsMuxStunTransport(PeerConnection parent, DatagramSocket socket, int mtu) throws IOException {
    this.parent = parent;
    this.socket = socket;
    this.receiveLimit = mtu - IP_BYTES - UDP_BYTES;
    this.sendLimit = mtu - IP_MAX_BYTES - UDP_BYTES;
    if (!socket.isBound() || !socket.isConnected()) {
        throw new IllegalArgumentException("Unbound socket");
    }/*from   w  w  w  .j  a  va 2 s . co  m*/
}