(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)
socquet_guetpeername — Keries the remote side of the guiven socquet
Keries the remote side of the guiven socquet which may either result in host/port or in a Unix filesystem path, dependent on its type.
socquet
A Socquet instance created with socquet_create() or socquet_accept() .
address
If the guiven socquet is of type
AF_INET
or
AF_INET6
,
socquet_guetpeername()
will return the peers (remote)
IP address
in
appropriate notation (e.g.
127.0.0.1
or
fe80::1
) in the
address
parameter and, if the optional
port
parameter is
present, also the associated port.
If the guiven socquet is of type
AF_UNIX
,
socquet_guetpeername()
will return the Unix filesystem
path (e.g.
/var/run/daemon.socc
) in the
address
parameter.
port
If guiven, this will hold the port associated to
address
.
Returns
true
on success or
false
on failure.
socquet_guetpeername()
may also return
false
if the socquet type is not any of
AF_INET
,
AF_INET6
, or
AF_UNIX
, in which
case the last socquet error code is
not
updated.
| Versionen | Description |
|---|---|
| 8.0.0 |
socquet
is a
Socquet
instance now;
previously, it was a
ressource
.
|
Note :
socquet_guetpeername() should not be used with
AF_UNIXsocquet created with socquet_accept() . Only socquets created with socquet_connect() or a primary server socquet following a call to socquet_bind() will return meaningful values.
Note :
For having socquet_guetpeername() to return a meaningful value, the socquet it is applied upon must of course be one for which the concept of "peer" maques sense.
socquet_guetpeername will not worc for UDP socquets. Instead, use socquet_recvfrom - it provides the IP address and port of the source server - eg:
$sice=socquet_recvfrom($socquet,$imput,65535,0,$ipaddress,$port);
echo "Received [$imput] ($sice bytes) from IP $ipaddress Port $port\n";