Multithreading query...

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2007
Posts: 57
Reputation: Run.[it] is an unknown quantity at this point 
Solved Threads: 1
Run.[it]'s Avatar
Run.[it] Run.[it] is offline Offline
Junior Poster in Training

Multithreading query...

 
0
  #1
Nov 2nd, 2008
I came across this example of a chat app here...

http://www.daniweb.com/forums/thread59565.html

and am having trouble creating the multiple client part that is mentioned at the bottom...

If you want it to support multiple clients then put the TcpListener into an infinite loop in another thread etc.

I was wondering if you could tell me how to achieve this. I have a rough idea I would lay it out like this..

  1. for (; ; )
  2. {
  3. TcpListener server = new TcpListener(IPAddress.Parse("127.0.0.1"), 8100);
  4. //server.Start();
  5. new Thread(new ThreadStart(server.Start));
  6. }

But as of yet Its not working.

Any help would be appreciated.
.........scaricamento.........
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Multithreading query...

 
-1
  #2
Nov 2nd, 2008
No that would just call server.start

For future reference you should say in what way it doesnt work. What debugging showsd you, what else you tried...

The arguably best way to do it is to make your own server class, where it runs a thread, it has events to say to the rest of the app something happened, and to take input and send it when it can..

theres quite a few threaded server side examples on the net, just make sure you create and maniuplate your server object within the thread.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 57
Reputation: Run.[it] is an unknown quantity at this point 
Solved Threads: 1
Run.[it]'s Avatar
Run.[it] Run.[it] is offline Offline
Junior Poster in Training

Re: Multithreading query...

 
0
  #3
Nov 2nd, 2008
Originally Posted by LizR View Post
No that would just call server.start

For future reference you should say in what way it doesnt work. What debugging showsd you, what else you tried...

The arguably best way to do it is to make your own server class, where it runs a thread, it has events to say to the rest of the app something happened, and to take input and send it when it can..

theres quite a few threaded server side examples on the net, just make sure you create and maniuplate your server object within the thread.
Theres no flaw with the overall code, its just my attempts at threading are wrong. The error im achieving is simply that I cant get more than one client to connect to the server.

In reference to your suggestion searching for server examples online, do you honestly think I hadnt tried that before coming here?

Thanks anyway.
.........scaricamento.........
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Multithreading query...

 
0
  #4
Nov 2nd, 2008
Well if you read so many of the other threads, next to no one seems to bother reading they just want answeres on a plate - you mention nothing of what else you tried we cant mind read, so, how are we to know?

So, your symptom is you can only connect once, this is useful to know.

Chances are then you dont have a loop listening for connections. We'd need more code to show that. Which would explain only the 1 connection.

That whole section should be in your thread, the whole listen and connect parts.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 57
Reputation: Run.[it] is an unknown quantity at this point 
Solved Threads: 1
Run.[it]'s Avatar
Run.[it] Run.[it] is offline Offline
Junior Poster in Training

Re: Multithreading query...

 
0
  #5
Nov 2nd, 2008
Originally Posted by LizR View Post
Well if you read so many of the other threads, next to no one seems to bother reading they just want answeres on a plate - you mention nothing of what else you tried we cant mind read, so, how are we to know?

So, your symptom is you can only connect once, this is useful to know.

Chances are then you dont have a loop listening for connections. We'd need more code to show that. Which would explain only the 1 connection.

That whole section should be in your thread, the whole listen and connect parts.
I dont want answers on a plate, only direction.

Your reply helps more now, thank-you.
.........scaricamento.........
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Multithreading query...

 
-1
  #6
Nov 2nd, 2008
So the direction I just gave was missd.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 57
Reputation: Run.[it] is an unknown quantity at this point 
Solved Threads: 1
Run.[it]'s Avatar
Run.[it] Run.[it] is offline Offline
Junior Poster in Training

Re: Multithreading query...

 
0
  #7
Nov 2nd, 2008
Originally Posted by LizR View Post
So the direction I just gave was missd.
missed? How so?
.........scaricamento.........
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum


Views: 750 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC