ID: 28136
Comment by: snodge at custard dot org
Reported By: daniele-dll at yahoo dot it
Status: Open
Bug Type: Sockets related
Operating System: Windows\Linux
PHP Version: 5.0.0RC1
New Comment:
Hi - I have the same issue, althought I am using PHP 5.0RC3 (cli) from
Linux. Here is some of the code that I am using - I added an echo
statement so that I could see what was happening when I connected with
more than one client at a time:
$port = 5000;
if (!$sock = socket_create_listen($port)) {
echo socket_strerror(socket_last_error());
}
if (!socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1)) {
echo socket_strerror(socket_last_error());
}
if (!socket_set_nonblock($sock)) {
echo socket_strerror(socket_last_error());
}
while (true)
{
$msgsock == FALSE;
do
{
@$msgsock = socket_accept($sock);
} while ($msgsock == FALSE);
echo "Received connection from $msgsock\n";
Previous Comments:
------------------------------------------------------------------------
[2004-04-24 16:56:04] daniele-dll at yahoo dot it
Description:
------------
Hi to all
i'm tring to write a little application with PHP using Socket, the
external module, not fsockopen function or similar.
I've noticed that, with this, and previous version of php, that after i
create a socket and set it as non blocking socket, when i try to connect
using
socket_get_option($SOCKET, SOL_SOCKET, SO_ERROR)
i recive EVER 0
Instead i should recive 115
If socket_get_option, with these params, return 0, it mean that
connection is done and i can send datas, but if i send datas i get a
warning that say that socket is in a connection state so i can't send
datas.
There is some parts of code:
$this->socket[$sock_id]['resource'] = socket_create(AF_INET,
SOCK_STREAM, SOL_TCP);
if (!is_resource($this->socket[$sock_id]['resource']))
die("Unable to create socket! " .
socket_strerror(socket_last_error()) . "\r\n");
if (!socket_set_option($this->socket[$sock_id]['resource'], SOL_SOCKET,
SO_REUSEADDR, 1)) {
die("Unable to set to as REUSABLE socket! " .
socket_strerror(socket_last_error($this->socket[$sock_id]['resource']))
. "\r\n");
after i set socket as reusable (but php gimme me the same problem
without this line too) and, after, if i need, i bind socket to a
specific IP and PORT
after there is this code:
@socket_connect($this->socket[$sock_id]['resource'],
$this->socket[$sock_id]['remote_host'],
$this->socket[$sock_id]['remote_port']);
while (($ris = @socket_get_option($this->socket[$sock_id]['resource'],
SOL_SOCKET, SO_ERROR)) == 115) {
echo "--> " . $ris . "\r\n";
}
echo "\r\n--> " . $ris . "\r\n";
If you run this code it will exit immedatly printing:
--> 0
Infact, after, if you try to write to socket, you will get a warning
I haven't modified php.ini, and i've tried to run this code, using only
socket extension, on windows and on linux
I use apache 1.3.29 on windows and on linux
bye
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28136&edit=1