![Pensando](http://static.forosdelweb.com/fdwtheme/images/smilies/scratchchin.gif)
El cliente se conecta perfectamente con el cliente, pero siempre me dice que no se envio el mensaje
codigo del Servidor
Código PHP:
#!/usr/local/bin/php –q
<?php
// Set time limit to indefinite execution
set_time_limit (0);
ob_implicit_flush();
// Set the ip and port we will listen on
$address = '192.168.0.1';
$port = 1024;
// Create a TCP Stream socket
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
if($sock != -1)
{
// Bind the socket to an address/port
if (socket_bind($sock, $address, $port))
{ echo("\nEscuchando por el puerto\n". $puerto);
// Start listening for connections
socket_listen($sock);
$sw=1;
//repetirlo hasta asegurarse que el cliente recbio el mensaje
while($sw==1) {
/* Accept incoming requests and handle them as child processes */
if ($client = socket_accept($sock))
{ echo ("\nConexion Aceptada con el cliente $client\n");
$ouput="Maximize"; //Mensaje que deseo enviar
if(!socket_write($client, $output))
echo "No se envio el mensage \n";
else {
$sw=2; //el cliente recibio el mensaje y rompo el ciclo
echo "Mensaje enviado $sw";
}
}
else { echo ("\nNo acepta la conexion del cliente"); $sw = 2; }
} //fin del while
}else die('Could not bind to address');
}
else die("\n error creando el socket");
// Close the master sockets
socket_close($sock);
?>
Warning: fsockopen() expects parameter 2 to be long, resource given in /home/sockets/socket.php on line 35
Warning: fputs(): supplied argument is not a valid stream resource in /home/sockets/socket.php on line 36
eRRRROrrrrrr
Código PHP:
$fp = fsockopen($address, $client, $errno, $errstr);
if (fwrite($fp, $output)) //ya intente con fputs
echo "ESCRIBIO DEL OTRO MODO\n ";
}
else echo "eRRRROrrrrrr\n";
![Negando](http://static.forosdelweb.com/fdwtheme/images/smilies/negar.gif)
![triste](http://static.forosdelweb.com/fdwtheme/images/smilies/frown.png)
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)