I am well versed in perl and have built many TCP clients and servers separately which have worked very well. I am now in a position, after much reading needing someone much wiser than I to put the two together.
My problem is as follows
TCP Client -> Connects to a remote end and maintains the connection. It talks a protocol and has keep alives within it. This works well and is based on IO::Socket and IO::Select modules of which there are many examples.
TCP Server -> Recieves TCP connections and handles data correctly. Again simple enough and I have a forking model so multiple connections can be handled as needed.
Now the problem I face is that the TCP Server needs to send data to the TCP Client in a non blocking manner, such that the TCP Client connection to a remote server must be maintained but it must recieved data from the TCP Server, when available.
So little ASCII art to help
TCP Client -> Connection to a remote end
^
|
TCP Server <- Receives TCP connections and handles data and should send the data to the TCP Client, while the TCP Client maintains the connection to the remote end.
My current code tried to combine the two, uses pipe for reading writing, however I am stuck as how to manage the select between the TCP Client to the remote server and the incoming data from the TCP Server, so they do not block each other.
It is also requirement for the TCP Server to handle multiple requests, so forking not a problem, but how those processes talk to the TCP Client, without blocking etc.
I am sure this is a fairly simple implementation however IPC is something I have not done in anger before and pointers welcome/required.
I have not posted code directly but can provide if needed.
A
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.