HighTechTalks DotNet Forums  

Sockets and threads in J#

Dotnet VJSharp microsoft.public.dotnet.vjsharp


Discuss Sockets and threads in J# in the Dotnet VJSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Roger Garrett
 
Posts: n/a

Default Sockets and threads in J# - 04-10-2005 , 02:05 PM






I have a couple of questions about sockets and threads in J#,

Any feedback is quite welcome.


I create a server socket:

ServerSocket serverSocket = new ServerSocket(m_nPortNumberServerSocket);

and then wait for incoming data with:

Socket ClientIncoming = ServerSocket.accept();

Once the accept() returns I then set up the streams:

DataOutputStream OutputStreamToClient = new
DataOutputStream(ClientIncoming.getOutputStream()) ;
DataInputStream InputStreamFromClient = new
DataInputStream(ClientIncoming.getInputStream());


As it is now it only handles one "connection" to one client at a time.


QUESTION(S) 1:

Q: Is it possible for a ServerSocket to actually handle multiple incoming
connections at
the same time?

Q: Could I, once it returns from the accept(), spawn off a thread for the
particular client
that just connected, setting up its own Input and Output Streams, and then
immediately
go back waiting for another incoming Client?

QUESTION(S) 2:


This is just about threads in general. I know that if I have a
thread-derived object I can
start up the thread by invoking its start() method. For example:

MyThreadDerivedClass myThread = new MyThreadDerviedClass();

MyThread().start();

And I know that I can stop the thread with:

MyThread().stop();

Q: Do I also need to get rid of it with a

MyThread.destroy():


Q: Is it possible for the thread itself to "get rid of itself"?
If it simply exits (eventually) from the run() method within the thread, does
that automatically cause it to cease its existence?
Should the thread invoke its own staop() method in order to get rid of itself?


- Roger Garrett


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.