SOCKET_STRERROR(3) 1 SOCKET_STRERROR(3)socket_strerror - Return a string describing a socket errorSYNOPSIS
string socket_strerror (int $errno)
DESCRIPTION socket_strerror(3) takes as its $errno parameter a socket error code as returned by socket_last_error(3) and returns the corresponding
explanatory text.
Note
Although the error messages generated by the socket extension are in English, the system messages retrieved with this function will
appear depending on the current locale ( LC_MESSAGES).
PARAMETERS
o $errno
- A valid socket error number, likely produced by socket_last_error(3).
RETURN VALUES
Returns the error message associated with the $errno parameter.
EXAMPLES
Example #1
socket_strerror(3) example
<?php
if (false == ($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "
";
}
if (false == (@socket_bind($socket, '127.0.0.1', 80))) {
echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($socket)) . "
";
}
?>
The expected output from the above example (assuming the script is not run with root privileges):
socket_bind() failed: reason: Permission denied
SEE ALSO socket_accept(3), socket_bind(3), socket_connect(3), socket_listen(3), socket_create(3).
PHP Documentation Group SOCKET_STRERROR(3)
Check Out this Related Man Page
SOCKET_LAST_ERROR(3) 1 SOCKET_LAST_ERROR(3)socket_last_error - Returns the last error on the socketSYNOPSIS
int socket_last_error ([resource $socket])
DESCRIPTION
If a socket resource is passed to this function, the last error which occurred on this particular socket is returned. If the socket
resource is omitted, the error code of the last failed socket function is returned. The latter is particularly helpful for functions like
socket_create(3) which don't return a socket on failure and socket_select(3) which can fail for reasons not directly tied to a particular
socket. The error code is suitable to be fed to socket_strerror(3) which returns a string describing the given error code.
PARAMETERS
o $socket
- A valid socket resource created with socket_create(3).
RETURN VALUES
This function returns a socket error code.
EXAMPLES
Example #1
socket_last_error(3) example
<?php
$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
die("Couldn't create socket: [$errorcode] $errormsg");
}
?>
NOTES
Note
socket_last_error(3) does not clear the error code, use socket_clear_error(3) for this purpose.
PHP Documentation Group SOCKET_LAST_ERROR(3)
Hi All,
When I execute a command on Unix and it says 'Permission denied'. What could be the reason and how can it be resolved?
Many thanks,
David (2 Replies)
I am new to this socket programming stuff. I have a problem to fix.. i got the error message. "CRITICAL 11/08/05 12:06:26 _getsockopt reports error. errno: 239"
can some please help me with this.. how do i go about fixing this error.
thanx in advance.. (0 Replies)
Hi,My system is not booting and at the startup it is getting struck.In HMC error code is coming as 0000, I know the reason of failing.I have few queries on recovery, please answer:1. I have mksysb of the system from which I can restore the system but problem is my few application mount point was a... (5 Replies)
Hi,
I constantly get this error as a script is run:
getcwd failed (Unix's errno 13; Permission denied)
Can anyone point at the location of this function by default in AIX?
Thanks! (1 Reply)