• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread processing  RSS feed

 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to know if we have socket open, how thread will come toknow if any data coming means how thread will know that data coming so i have to listen,if it is not coming i have close the thread..
Please let me know
Thanks
angela
 
Jerry Pulley
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angela,
You could arrange for the sender to transmit some code that indicates end-of-data.
Jerry
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Jerry,
I want to know what should I have to implement on Client side for this..
Thanks
Angela
 
Ben Roy
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should go check out the posts in Sockets and Internet Protocols forum. I had this exact question and many more along the same line in the past week. In particular look at the post called:
Successful Applet Socket Connection http://www.javaranch.com/ubb/Forum8/HTML/000181.html
Which will have an example of how to create a BufferedReader and listen for input on the socket. Hope that helps!
 
Neeraj Thakkar
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Angela,
I think u r confused. There is nothing like how thred will come to know it's upto you what u want from a thread to do for you.
If u wish that ur thread should wait for messages u can give code for it to listen at the specific port number using sockets here thread will keep on waiting untill it receives some data.
When u ask of when it should disconnect and terminate then u can specify a particular message like if the incoming data is QUIT or BYE as u wish then the connection should be closed and thread terminated.
Neeraj Thakkar
------------------
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!