Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

socket events  RSS feed

 
A. Wolf
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i have copied a simple server/client echoing of data, and it works fine. i have also played around with it and have a basic idea of how I can apply it to whatever i need to make. I'm wondering if there is a way to listen for data on an inputstream or how would it be done? right now I've created a separate thread that checks the input stream every second, and if something has "arrived" it prints it and repeats. I know that can't be the correct or most efficient way to do it, and I would like to know what the equivalent of an ActionListener to a button is for a socket? SocketListener?
thanks
 
A. Wolf
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I know if there is data in the input stream coming from a server? tutorials, references anything would be appreciated. how would you do it?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to look at the java.nio packages in JDK 1.4; in particular java.nio.channels.SocketChannel and java.nio.channels.Selector. Look at this article for some info on getting started.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!