Hi,

If you only need to make a connection to the server every ten minutes you will be saving a lot of resources if you use a cron job to connect at intervals instead of keeping a permanently open connections. Creating a cron job is quite simple, if you type

man 5 crontab

you will be able to read more about it (at least in linux - a poor substitute exists in windows called scheduled tasks)

With this approach you just need to call fsockopen to do connect to your server and do the needful.





Tan Ai Leen wrote:

Hi Raditha,

Thanks, I have a better idea of how to write the codes. But I wonder, to check that the connection to the external server is on, where should I place the code? I need to do this every 10 minutes. If the connection is dropped, I have to reconnect. Where should I place this check? If I place it in the while(true) loop, I will be checking every few miliseconds rite? That will be too frequent. What about in another script? Will I be able to check that the connection is on?

Regards,
Ai Leen

Raditha Dissanayake wrote:

Hi Tan,

If you are connecting to another server you are using a client socket you do not need to make a server socket. If you need to listen for connections make use of a server socket. To give you an example your browser makes use of client sockets while apache makes use of server sockets. That is an over simplified view of things but hope it helps you understand things better.

Generally working with client sockets is easier.

best regards



--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/         | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to