Тема: Сокет и php
Показать сообщение отдельно
Старый 09.06.2011, 18:56
bums3230 вне форума Посмотреть профиль Отправить личное сообщение для bums3230 Найти все сообщения от bums3230
  № 3  
Ответить с цитированием
bums3230

Регистрация: Jan 2009
Сообщений: 34
Английский я плохо знаю поэтому мало, что понял. Допустим беру такой php файл.
Кидаю его в каталог (www/mydomain.ru) моего хостинга. И по прежнему соединение не устанавливается. Подскажите что делаю не правильно.

PHP код:
<?php 
// Set time limit to indefinite execution 
set_time_limit (0); 

// Set the ip and port we will listen on 
$address '192.168.0.100'
$port 9000

// Create a TCP Stream socket 
$sock socket_create(AF_INETSOCK_STREAM0); 
// Bind the socket to an address/port 
socket_bind($sock$address$port) or die('Could not bind to address'); 
// Start listening for connections 
socket_listen($sock); 

/* Accept incoming requests and handle them as child processes */ 
$client socket_accept($sock); 

// Read the input from the client – 1024 bytes 
$input socket_read($client1024); 

// Strip all white spaces from input 
$output ereg_replace("[ \t\n\r]","",$input).chr(0); 

// Display output back to client 
socket_write($client$output); 

// Close the client (child) socket 
socket_close($client); 

// Close the master sockets 
socket_close($sock); 
?>