TCP vs UDP on video stream

Drawbacks of using TCP for live video: As you mentioned, TCP buffers the unacknowledged segments for every client. In some cases this is undesirable, such as TCP streaming for very popular live events: your list of simultaneous clients (and buffering requirements) are large in this case. Pre-recorded video-casts typically don’t have as much of a … Read more

BOOST ASIO – How to write console server

The problem is: How can I attach (or write) console, which can calls above functionalities. This console have to be a client? Should I run this console client as a sepearate thread? You don’t need a separate thread, use a posix::stream_descriptor and assign STDIN_FILENO to it. Use async_read and handle the requests in the read … Read more

Java Server – Multiple ports?

It’s not possible to for a single instance of ServerSocket to listen to multiple ports. You can of course have multiple ServerSockets. However, as you already know, ServerSocket.accept blocks. What you can use instead is a ServerSocketChannel. They’re used in a similar way, but do not block. If there are no pending connections when ServerSocketChannel.accept … Read more

Java TCP socket: data transfer is slow

You do not want to write single bytes when you are transferring large amounts of data. import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; public class Transfer { public static void main(String[] args) { final String largeFile = “/home/dr/test.dat”; // REPLACE final int BUFFER_SIZE = 65536; new Thread(new Runnable() { public … Read more