use of java.net.DatagramPacket in project camel by apache.
the class SyslogSpringNettyTest method testSendingRawUDP.
@Test
public void testSendingRawUDP() throws IOException, InterruptedException {
MockEndpoint mock = getMockEndpoint("mock:stop1");
MockEndpoint mock2 = getMockEndpoint("mock:stop2");
mock.expectedMessageCount(1);
mock2.expectedMessageCount(1);
mock2.expectedBodiesReceived(message);
DatagramSocket socket = new DatagramSocket();
try {
InetAddress address = InetAddress.getByName("localhost");
for (int i = 0; i < messageCount; i++) {
byte[] data = message.getBytes();
DatagramPacket packet = new DatagramPacket(data, data.length, address, serverPort);
socket.send(packet);
Thread.sleep(100);
}
} finally {
socket.close();
}
assertMockEndpointsSatisfied();
}
use of java.net.DatagramPacket in project camel by apache.
the class MinaDataFormatTest method testSendingRawUDP.
@Test
public void testSendingRawUDP() throws IOException, InterruptedException {
MockEndpoint mock = getMockEndpoint("mock:syslogReceiver");
MockEndpoint mock2 = getMockEndpoint("mock:syslogReceiver2");
mock.expectedMessageCount(1);
mock2.expectedMessageCount(1);
mock2.expectedBodiesReceived(message);
DatagramSocket socket = new DatagramSocket();
try {
InetAddress address = InetAddress.getByName("127.0.0.1");
for (int i = 0; i < messageCount; i++) {
byte[] data = message.getBytes();
DatagramPacket packet = new DatagramPacket(data, data.length, address, serverPort);
socket.send(packet);
Thread.sleep(100);
}
} finally {
socket.close();
}
assertMockEndpointsSatisfied();
}
use of java.net.DatagramPacket in project camel by apache.
the class NettyManyUDPMessagesTest method testSendingManyMessages.
@Test
public void testSendingManyMessages() throws Exception, InterruptedException {
MockEndpoint stop1 = getMockEndpoint("mock:stop1");
MockEndpoint stop2 = getMockEndpoint("mock:stop2");
stop2.expectedMessageCount(messageCount);
stop1.expectedMessageCount(messageCount);
DatagramSocket socket = new DatagramSocket();
try {
InetAddress address = InetAddress.getByName("127.0.0.1");
for (int i = 0; i < messageCount; i++) {
byte[] data = message.getBytes();
DatagramPacket packet = new DatagramPacket(data, data.length, address, serverPort);
socket.send(packet);
Thread.sleep(100);
}
} finally {
socket.close();
}
assertMockEndpointsSatisfied();
}
use of java.net.DatagramPacket in project bigbluebutton by bigbluebutton.
the class UdpSocket method receive.
/** Receives a datagram packet from this socket. */
public void receive(UdpPacket pkt) throws java.io.IOException {
DatagramPacket dgram = pkt.getDatagramPacket();
socket.receive(dgram);
pkt.setDatagramPacket(dgram);
}
use of java.net.DatagramPacket in project RPlay by bencall.
the class AudioServer method request_resend.
/**
* Ask iTunes to resend packet
* FUNCTIONAL??? NO PROOFS
* @param first
* @param last
*/
public void request_resend(int first, int last) {
System.out.println("Resend Request: " + first + "::" + last);
if (last < first) {
return;
}
int len = last - first + 1;
byte[] request = new byte[] { (byte) 0x80, (byte) (0x55 | 0x80), 0x01, 0x00, (byte) ((first & 0xFF00) >> 8), (byte) (first & 0xFF), (byte) ((len & 0xFF00) >> 8), (byte) (len & 0xFF) };
try {
DatagramPacket temp = new DatagramPacket(request, request.length, rtpClient, session.getControlPort());
csock.send(temp);
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations