Re: [xSocket-develop] Some explanation of non-blocking I/O and multiplex
Status: Inactive
Brought to you by:
grro
|
From: Gregor R. <gre...@gm...> - 2010-04-28 04:00:53
|
Hi, xSocket supports non-blocking writing by a flushMode property. INonBlockingConnection nbc = ... nbc.setFlushmode(FlushMode.ASYNC); Default is SYNC. If sync, the write method will blocking until the data is written to the OS-level socket out buffer. If async the data will be buffered by xSocket internally. The method returns immediately. Please refer to http://xsocket.sourceforge.net/core/tutorial/V2/TutorialCore.htm. Multiplexing will be used to share the same pyhsical connection. This approach helps to used the number of open physical connections. There are UseCase where the number of concurrent connections have to keep small. Gregor > ----- Original Message ----- > From: Kasper Grubbe > Sent: 04/26/10 10:34 PM > To: xso...@li... > Subject: [xSocket-develop] Some explanation of non-blocking I/O and multiplex > Hi, I am playing with networking sockets for the very first time, and while playing around with Java networking in java.net.Socket I was able to build a small socket server that didn't scale so much because i built it with a thread for each client. I have now switched to xScockets, and I have questions about a couple of words that you are using for explaining your framework. Non-blocking IO: Wikipedia writes: "Asynchronous I/O, or non-blocking I/O, is a form of input/output processing that permits other processing to continue before the transmission has finished.". Consider the following code: ArrayList<INonBlockingConnection> clients = new ArrayList<INonBlockingConnection>(); public void sendToClients(String msg) { for(INonBlockingConnection client : this.clients) { client.write(msg); } } Does that mean that a client that is slow to recieve the msg, would not block for the next client in the list? And does it mean that client.write(msg) would terminate the same moment that it is run? My next question is what multiplexing is, and what it is useful for? Which types of applications? Thanks, Have a fantastic day :) -- Kasper Grubbe Computer Science AP ------------------------------------------------------------------------------ _______________________________________________ xSocket-develop mailing list xSo...@li... https://lists.sourceforge.net/lists/listinfo/xsocket-develop |