This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I use NIO api to read content from socket in client side?  RSS feed

 
Joab
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a question about using socket. In my business, I need to write a java program as client to connect the remote socket via TCP. And this client program need to handle some content transfered from server side. Can I use NIO api to achieve this? I don't want to use blocking connection to do this. Thanks your help in advance.

Regards,
Joab.
 
Catalin Merfu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NIO makes sense when implementing the server rather than the client. The purpose of NIO is to create servers that use a pool of threads to handle client requests rather than a dedicated thread for each connected client.
The improvements when using NIO can be observed when servicing thousands connected clients.

On the client side NIO doesn't make sense, just spawn a new thread for communication and use normal blocking sockets.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!