[nycphp-talk] Related Socket Question...
Hans Zaunere
zaunere at yahoo.com
Wed Jan 29 16:59:34 EST 2003
--- Jim Musil <jim at nettmedia.com> wrote:
> On 1/29/03 4:22 PM, "Hans Zaunere" <hans at nyphp.org> wrote:
>
>
> >
> > This is the right way; aside from using cURL :) Or you could use real
> > sockets (as opposed to streams, of which fsockopen() is) if you have a
> lot of
> > time to kill.
> >
>
>
> How exactly does PHP "open a socket"?
At the OS level, the same as anything else (ie telnet).
> Is it using something that is part of the PHP engine?
Partially; the nicety of being able to do fsockopen("udp://somewhere.com") or
fsockopen("tcp://somewhere.com") is a PHPism. I think how PHP does this has
changed and/or improved to a certain extent recently, but I know little more
of the details.
http://www.php.net/manual/en/streams.php
http://www.php.net/manual/en/ref.stream.php
> or is it using some other system call?
Streams, whether stdio or PHP, all use the same system calls at one point;
they are just various wrappers.
> For instance, how close are the following operations?
>
> 1. Using fsockopen() to connect to port 80 on a remote server.
>
> AND
>
> 2. Using the shell command telnet to connect to PORT 80 on a remote
> server.
As far as Linux, the OS, is concerned, identical.
> The reason I ask is both are moving very slowly on one of our Linux
> servers.
> I'm suspicious of xinetd because I had a previous problem with FTP'ing that
> was solved through xinetd's conf files.
I stay away from super-servers so maybe I've lost track of what it does, but
xinetd should only be involved with incoming connections (which, I suppose
*could* affect FTP). But doing just a telnet should have no difference.
Check DNS latency, network congestion, kernel/hardware errors, etc.
=====
Hans Zaunere
President, New York PHP
http://nyphp.org
hans at nyphp.org
More information about the talk
mailing list