I am trying to write a process that essentially acts as an conduit between two other proceses. I want to open a serversocket A and a client socket B. Something like.
$server = IO::Socket::INET->new(
Listen => 5,
LocalAddr => 'localhost',
LocalPort => $local_port,
Proto => 'tcp') or die "Cant create server socket: !";
while ($client = $server->accept)
$proxy = IO::Socket::INET->new(
PeerAddr => $proxy_host,
PeerPort => $proxy_port,
Proto => 'tcp')
or die "cannot create proxy socket: $!"
# At this point here I want to connect the $proxy file handle and
# the $client file handle ..
By connect I mean I want the any op from $client to be shoved into the ip of $proxy and any op from $proxy to be shoved in the ip of $client. Clear .. no not to me either I am sure I am doing summat wrong.
Now I guess I could do this by spawning 2 threads one to read and one to write then just bucket the data across however I am looking for a simpler solution.
I would be keen to hear anyones suggestions. I half think I am missing some thing and should not be even attempting this so please tell me I am being dumb if you see that to be the case.
Thanks very much for your time.