in reply to sockets and such in Perl
Sockets is somewhat vague, anyway all sockets methods I know of are bidirectional. So, first of all, no need to have a couple of them - they're not pipes or fifos! This should half the complexity :)
Second, you probably have to decide who's the server and who's the client. Even if it may seem strange, I'd put the man-in-the-middle as a client, simply because... I forecast it will be simpler to code. A matter of taste and of forecasting powers, anyway.
This issue, tough physically completely independent on the following algorithm, is logically connected. How would you implement it inside a single process, reading from three files? Here you have much the same scenario, only with a bit of control logic to avoid reading more than you need. Again, the man-in-the-middle process will be the master driver, while the other two will act as slaves (i.e. servers).
The first and third process (i.e. the "endpoints"):
The second follows the same logic as a "single-process" computation: each time the process wants to read from one of the "side" file, it sends a fake command (a simple newline will do) to the corresponding far process, then reads the answer as if it were reading from a file. The core algorithm does not need to be changed, as you can see.Open file Open socket in server mode Accept incoming request Loop: read a request from the socket if request is "stop" exit else read name from file and send back to the socket
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sockets and such in Perl
by scotchfx (Sexton) on Jul 03, 2005 at 17:26 UTC | |
by polettix (Vicar) on Jul 03, 2005 at 18:00 UTC | |
by scotchfx (Sexton) on Jul 03, 2005 at 18:30 UTC | |
by polettix (Vicar) on Jul 04, 2005 at 10:06 UTC |