![]() |
| | #1 |
| Registered User Join Date: Nov 2004 Location: india
Posts: 493
| Multiple Threads, One listener. Thanks. |
| PING is offline | |
| | #2 |
| critical genius Join Date: Jul 2008 Location: SE Queens
Posts: 5,185
| 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. |
| MK27 is offline | |
| | #3 |
| Malum in se Join Date: Apr 2007
Posts: 3,188
| 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.
__________________ Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off. 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,768
| 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 |