Re: [PHP-DEV] restructuring/rewriting parts of networking code From: Stig Venaas (Stig.Venaas <email protected>)
Date: 08/08/00

Hi all

I've looked through the networking code and done some thinking. I
would like to implement a function hostconnect that takes the
arguments hostname (or IP-address as string), protocol (TCP/UDP),
blocking/noblocking and timeout. It returns a socket. As a special
case it should also do domain sockets if hostname starts with /.
I guess I also need a last argument for returning error-messages.

The reason I want to have hostconnect, is that one hides away
the address dependent parts, and one can inside hostconnect
loop through all the available addresses of a host until one
connects successfully. It can easily be implemented using getaddrinfo
on platforms that support it, I'll do something else for those that
don't.

The places I've found networking code are:

main/fopen-wrappers.c
win32/sendmail.c
ext/ftp/ftp.c
ext/hyperwave/hg_comm.c
ext/standard/dns.c
ext/standard/fsock.c
ext/mysql/libmysql/libmysql.c
ext/mysql/libmysql/my_pthread.c

I think all but my_pthread.c and dns.c can make good use of hostconnect,
making them completely protocol independent. The code will be cleaner too.
dns.c uses several resolver functions, I would like to do those afterwards,
don't think I need to plan all those yet, would like to discuss them later.
I need to check my_pthread.c later too.

There is one thing in ftp that need to be solved later, and that's the
handling of active ftp, I might have to make a combined bind-listen or
something, but I think that can be done independently from hostconnect
too.

The hostconnect is very much the same as the internals of the fsockopen
function.

So, what I would like to do for starters is to implement a basic version
of hostconnect with enough functionality that I can use it inside
php_fopen_url_wrap_http (and php_fopen_url_wrap_ftp). I can get back to
you when I've implemented that, and add it to the CVS after you've had
a look at it. I kinda like doing one step at the time. Partly because
I've only got time to do this in between other things, and it's good
to get things tested as I go.

Does this sound okay, or do you really think I should plan the entire
wrapper API before I start?

Stig

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>