• Post Reply Bookmark Topic Watch Topic
  • New Topic

asynchronous socket

 
Ariffin Ahmad
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does anyone knows how can we implement asynchronous socket connection, so that my the socket can inform me if there is an incoming connection, incoming data, instead of i'm checking the socket everytime?...
 
Sam Moran
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question regarding the same thing! How do you sense when the server has stopped sending data? I have a socket that is open with an FTP server and when I open the socket I receive a stream of text telling me that I have connected. I need to sense some sort of end of stream, -1 is not working! Does anyone have any information on this? Thank you.
 
Jon Dornback
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you may want to look in to java1.4 nio classes. they implement "non-blocking io", meaning that a program doesn't have to wait for an incoming connection - it can be doing other things in the meantime. not sure if that's what you're looking for, but it's a starting point.
for determining the end of a stream of input, that is going to be different for each program. can you parse the input for some sort of "end of stream" string? otherwise, if the other end doesn't close the connection, you will have to assume that more data could be coming.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!