In my experience, you need to open 2 sockets: one to to listen for and accept incoming connections, and the other to connect to the other server.
If I'm understanding your 2 posts correctly, I would imagine a processing flow like:
- Remote Server listens on a port for incoming connections.
- When an incoming connection is detected, delegate a worker process/thread.
- Worker accepts the connection while the Remote Server resumes waiting for incoming connections.
- Worker receives the message and validates it.
- If validation fails, worker sends a negative response, closes the connection then becomes idle (or terminates itself).
- Otherwise, worker sends a positive response, closes the connection then processes the message.
- If no results message needs to be sent, worker becomes idle (or terminates itself).
- Otherwise, worker opens a socket, connects to your Local Server and sends the results message.
- Worker waits for positive/negative response. Once received, closes the connection.
- Worker performs any needed follow up based on the positive/negative response.
- Worker becomes idle (or terminates itself).
In the case where the Remote Server is initiating the transaction, a worker would proceed as above as though it were sending a results message. Any results sent back from the Local Server would be handled be handled the same as accepting requests as above.
I am sure there are modules/frameworks in CPAN that can handle the network part, especially if the communication between the Remote and Local servers is HTTP based.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.