![]() |
| | #1 |
| Registered User Join Date: Nov 2004 Location: india
Posts: 493
| Multiple Threads, One listener. Thanks. |
| PING is offline | |
| | #2 |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Not that I have experience doing exactly this but I would say go with the former idea (one listener and an ID for recipient); multiple ports seems silly and implies the number of connnections is small enough to be dealt with by a single server port anyway.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS |
| MK27 is online now | |
| | #3 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,927
| You will have to use a critical section to control access to the send function though, otherwise the messages may get garbled with one another. If you assign a particular thread to process a particular type of information then all incoming packets fo that type can be forwarded to teh appropriate thread, but if you have types of information that all threads can possibly have requested, then you need to have teh individual threads keep track of what information they requested and reject any pacets they didnt request, this adds overhead in that incoming packets have to be dispatched to each possible thread. I cant think off hand why you would need this complicated scheme.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 03-27-2009 at 12:13 PM. |
| abachler is offline | |
| | #4 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| Why not give each request a unique tag (an integer). This tag gets passed back along with the response, where it can be dispatched to whichever thread allocated that tag. You could use the thread_id itself as the tag, probably.
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot |
| brewbuck is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with multiple threads | Cogman | Windows Programming | 2 | 07-05-2009 09:40 AM |
| Multiple Threads | NuNn | C Programming | 3 | 03-14-2009 11:29 PM |
| Question about Multiple threads and ring buffer. | qingxing2005 | C Programming | 2 | 01-15-2007 12:30 AM |
| Race condition: getting multiple threads to cooperate | FlyingDutchMan | C++ Programming | 10 | 03-31-2005 05:53 AM |
| Modeless Dialogs in Multiple threads | MrGrieves | Windows Programming | 0 | 06-22-2004 01:33 PM |