| | |
Multithreading query...
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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..
But as of yet Its not working.
Any help would be appreciated.
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..
C# Syntax (Toggle Plain Text)
for (; ; ) { TcpListener server = new TcpListener(IPAddress.Parse("127.0.0.1"), 8100); //server.Start(); new Thread(new ThreadStart(server.Start)); }
But as of yet Its not working.
Any help would be appreciated.
.........scaricamento.........
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
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.
•
•
•
•
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.
In reference to your suggestion searching for server examples online, do you honestly think I hadnt tried that before coming here?
Thanks anyway.
.........scaricamento.........
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
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.
•
•
•
•
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.
Your reply helps more now, thank-you.
.........scaricamento.........
![]() |
Similar Threads
Other Threads in the C# Forum
- Previous Thread: access permission on registry keys
- Next Thread: Passing Data
Views: 750 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button buttons c# chat check checkbox class client code color combobox control conversion csharp custom database datagridview dataset datetime degrees draganddrop drawing encryption enum excel file files form format forms ftp function gdi+ http image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






