Re: Help with php server and sockets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2007-05-23 at 16:24 -0700, Adz07 wrote:
> i want to set up a php server that can communicate with a client (CLI PHP
> Script). I can setup the server socket fine. What i need to know is whether
> it is possible for the client to call a function in the servers php code and
> the server return the data ready for the client to process??
> 
> To start, if anyone could tell me how to use a socket connection from a CLI
> client to a CLI server to retreive an array (it'll do for now :)  ....if its
> even possible that is!
> 
> Sorry if thats not the best explanation!

You just need some sort of agreed upon protocol. For instance the server
might treat any input from the client that is terminated by a newline as
a command. So for instance the client might send:

    get array

Then the server would parse the request and realize that the client
wants an array. Then it would echo the data in some manner understood by
the client (XML, SOAP, PHP serialized data, JSON, etc). The server would
also send some kind of terminator indicating the end of the data (which
could be as simple as closing the connection). Then the client just
needs to parse what it received.

Hope that helps.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux