Example usage for java.net DatagramPacket DatagramPacket

List of usage examples for java.net DatagramPacket DatagramPacket

Introduction

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

Prototype

public DatagramPacket(byte buf[], int length) 

Source Link

Document

Constructs a DatagramPacket for receiving packets of length length .

Usage

From source file:org.opendaylight.lispflowmapping.integrationtest.MappingServiceIntegrationTest.java

License:asdf

private DatagramPacket receivePacket(DatagramSocket receivedSocket, int timeout) throws SocketTimeoutException {
    try {//www. j  a v  a2 s  . c o m
        byte[] buffer = new byte[4096];
        DatagramPacket receivePacket = new DatagramPacket(buffer, buffer.length);
        LOG.trace("Waiting for packet from socket...");
        receivedSocket.setSoTimeout(timeout);
        receivedSocket.receive(receivePacket);
        LOG.trace("Recieved packet from socket!");
        return receivePacket;
    } catch (SocketTimeoutException ste) {
        throw ste;
    } catch (Throwable t) {
        fail();
        return null;
    }
}