Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Passing a TCP connection from one Perl program to another

by muba (Priest)
on Oct 16, 2009 at 04:11 UTC ( [id://801495]=note: print w/replies, xml ) Need Help??


in reply to Passing a TCP connection from one Perl program to another

I'm afraid the only way is to make the accepting program act as a proxy between the other program and the remote machine.

So basically, it'd look like this:

  1. Program A: incoming connection
  2. Program A accepts and does whatever needs to be done
  3. Program A finds that it is now Program B's responsibilty. Either 1) using the existing TCP connection between A and B, or 2) by establishing a new connection, A informs B about this.
  4. Program A maintains the connection to the host but doesn't do anything except for bidirectionally relaying all data it receives from either party.
  5. When program B is done as well, it tells A about it, either by sending a specific code over the existing connection or simply closing the one created in step 3.2.
  6. Program A performs the goodbye rituals as per protocol (such as sending a 'everything succesful' sort of status message) and closes the connection to the remote as well.

I could be mistaken, of course, but to my knowledge this is the only way to fulfill your requirements. It'd be much simpler, of course, if Program A could simply say "Hey, listen, I can't do anything for you anymore, but here, have this state information (session ID or just the session data, something like that, so that Program B will know what it's working with) and contact my friend, program B. You can find him on this-and-that address."

  • Comment on Re: Passing a TCP connection from one Perl program to another

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://801495]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-26 03:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found