• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Thread processing

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks Jerry,
I want to know what should I have to implement on Client side for this..
Thanks
Angela
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
------------------
reply
    Bookmark Topic Watch Topic
  • New Topic