944,101 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2305
  • Java RSS
Jun 8th, 2005
0

Need to open two concurrent Sockets

Expand Post »
I have an applet that needs to have a sending socket and a receiving socket, each unidirectional, on ports 2001 and 2002. now, i tried making each one in a thread and it did not work. can someone give me a code example as to how to do this? i am desperate for an answer at this point. thank you muchly
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
twocentwhoracle is offline Offline
3 posts
since Jun 2005
Jun 8th, 2005
0

Re: Need to open two concurrent Sockets

I'm not completely sure you can do this, but if you can, an extra class that extends Thread should work:

Have the normal class make the calls to the thread class:
Java Syntax (Toggle Plain Text)
  1. public class b
  2. {
  3. public b()
  4. {
  5. new ThreadClass(socket,2001);
  6. new ThreadClass(socket,2002);
  7. }
  8. }
  9.  
  10. public class ThreadClass extends Thread
  11. {
  12. public ThreadClass(Socket socket, int port)
  13. {
  14. //do some crap
  15. }
  16. }
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Very New to java, skeleton of program given
Next Thread in Java Forum Timeline: Suggest me books on Java concept.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC