I am currently writing naive network code for a project and a mate hinted me at the possibility that when I send a package of information from the server to all clients in an it
Of course, when you write to a socket, this write is buffered. Socket object have a setSendBufferSize()
method for setting this buffer size. If your write can be cached in this buffer, then of course, you may iterate immediately on the following socket. Otherwise this buffer need to be flushed to the client immediately. So, during flushing you are going to be blocked. If you want to avoid being blocked while flushing the buffer, you have to use a SocketChannel
in non blocking I/O.
Anyway, the best option for writing to many socket concurrently, is to manage each socket with a different thread, so that all writes may be executed at the same time.