954,176 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need to open two concurrent Sockets

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

twocentwhoracle
Newbie Poster
3 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

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:

public class b
{
     public b()
     {
             new ThreadClass(socket,2001);
             new ThreadClass(socket,2002);
     }
}

public class ThreadClass extends Thread
{
       public ThreadClass(Socket socket, int port)
       {
              //do some crap
       }
}
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You