I wrote a similiar IO Socket script by what you are describing. I used perl and the IO::Socket module. It was pretty straight forward and their is plenty of docs out there on that module.
Just a thought.... Good Luck! Daniel ----- Original Message ----- From: "René Fournier" <[EMAIL PROTECTED]> To: "php" <[EMAIL PROTECTED]> Sent: Thursday, July 17, 2003 4:17 PM Subject: [PHP] The stupidest question of the month. > (Okay, now you're prepared...) > > I need to write a little program that opens and maintains a TCP socket > connection to a server across the Internet. This little program would > wait for messages from the server it's connected to, then record those > messages and send a kinda of acknowledgment "Got it". > > I've written a fair amount of PHP scripts for web sites, but nothing > that would run in the background, independently say of a web browser or > server. In other words, I don't really know what I'm doing, or where to > start. I've looked at PHP.net's socket docs, but everything seems to > scream experimental, use at own risk, etc. This little program, while > operationally simple, needs to be very reliable. For example, if the > socket connection dies for some reason, it would know to open a new > one. Or if the server doesn't acknowledge my little program's periodic > "Hey, you still there"-type pings, it would close the connection and > reopen a new one. (In fact, at the end of this message I'll list the > basic operation and flow of the little program as stated by the company > running the server to which I would connect.) > > In any case, what I want to know is, can this be done with PHP on a > run-of-the-mill PHP-savvy ISP? Or would I need something more > configurable? Would I need to learn C and compile a UNIX program to do > this? Any ideas where to start? Resources, links? Anything would be > much appreciated.... Thanks very much in advance. > > Here is how the little program should function, according to the > Company: > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > > The following describes the basic operation and flow needed within the > DC: > > Setup and open tcp socket using IP address and port number13 > Send a Password_DS to the DS > Send a Resend_DS to the DS > Enter infinite loop: > Wait for messages from the DS > Upon receipt of a Send_DS from the DS > Store message contents appropriately > Send a Send_DS_Ack to the DS > Send message contents to other CSP applications > Upon receipt of a Ping_DS > Respond with a Ping_DS_Ack > Upon receipt of a Status_DS > Respond with a Status_DS_Ack > If needed, send message to other CSP process(es) > Periodically, send a Ping_DS to the DS > If the Ping_DS transmit fails > Clean-up and restart the socket connection > If a Ping_DS_Ack is not received from the DS > Clean-up and restart the socket connection > > In this sequence, the data formats for the messages must follow the > requirements > shown earlier. I.e., the Startup_DS message must include the correct > client type; > the Send_DS_Ack messages must include the hostID and sequenceID data, > etc. The > data contents received by the DC will usually be formatted and > forwarded to > other CSP-internal procedures for further processing. > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > > ...Rene > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php