Datagram Socket & Datagram Channel performance
Hi,
I have been writing a video streaming server, and i have found that it does not perform anywhere near how it should (with available disk and network bandwidth). I have split the program down, and discovered that sending UDP packets appears to be running really slowly. Here is an example of the code i am using (sending blank packets for speed).
<code>
while (totalBytesSent < 150000000)
{
totalBytesSent += (188 * 7);
udpPacket.setData(payload);
udpPacket.setAddress(InetAddress.getByName("239.2.1.10"));
udpPacket.setPort(23232);
udpSocket.send(udpPacket);
}
</code>
it sends 150 megs of data in about 30 seconds = 5 meg/sec which is no where near the available bandwidth (gigabit lan).
So, i thought maybe the NIO packages are the solution, but i get similar performance using the datagram channel and byte buffers with this code:
<code>
while (totalBytesSent < 160000000)
{
inStream.read(fileBuf);
buffer.put(fileBuf);
buffer.flip();
bytesSent += udpChannel.send(buffer, destAddress);
buffer.position(0);
totalBytesSent += (188*7);
}
</code>
what am i doing wrong? is there a better way of sending data over a network? what I am essentially doing is trying to read directly from a file on the disk and send it straight over the network as fast as possible. Any help much appreciated.
Cheers
Robert Clarkson

