Package proposal: Sockets
| From: | Stephan Seidt | Date: | Fri, 21 Mar 2003 22:18:36 +0000 |
| Subject: | Package proposal: Sockets | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-14545@lists.php.net to get a copy of this message | ||
Hello,
I want to propose you this package once again and I want
to talk about the internal structure of the package so that
it will fit to everybody's needs.
By trying to provide the best and most extensionable structure
for a socket api, this package should have every possibility to
create nearly every possible type of socket.
That means to support the different domains, socket types, protocols
and to act either as server or client node. But we shouldn't exaggerate.
Something like this end-user interface could just be a nice solution :
$socket = Socket::factory('www.example.com', 80, SOCKET_TCP, SOCKET_CLIENT);
I know that a basic tcp socket in its initial state can be used as
client or server by choosing either a connect call to get connected to
a remote socket or to use the bind, listen and accept functions to
establish a server socket which is waiting for other connections.
But there must also be a function to 'activate' the socket, e.g.:
$socket->activate() // $socket->run() // $socket->create()
But the following solution is imho also a good solution:
$socket = Socket::Factory('www.example.com', 80, SOCKET_TCP);
$socket->connect(); // To connect to the remote socket$client = $socket->listen(); // To act as a server (listen) socket --- How would the internal abstraction-strucure look like? Some examples: TCP: Common -> Stream -> TCP UDP: Common -> Datagram -> UDP UNIX: Common -> UNIX ... other protocols ... I think the domain section of the socket AF_INET / AF_UNIX (LOCAL) can be ignored if we talk about the structure. At least I want to ask you know where this stuff would be stored. It consists of more than one file and can't just be throwed somewhere into the Networking category. There should be at least a directory where the files can be stored. --- I also want to mention the possibility of backwards-compatiblity to the Net_Socket class which supports the php-stream sockets, because this new package would need php's socket extension. (It already works on (almost?) every platform.) --- What's your opinion about that? bye