PDA

View Full Version : create socket error



freestar
چهارشنبه 28 مرداد 1388, 21:08 عصر
سلام :
در مورد create socket برای ارتباط TCP اکر دوستان عزیز مطلبی دارند کمک کنند تا از این خطا رهایی یابیم :
Call to undefined function socket_create() in C:\wamp\www\c1.php on line 15
که در اجرای اسکریپت ذیل بوده :

<?php echo " create" ?>
<?php
error_reporting(E_ALL);

/* Allow the script to hang around waiting for connections. */
set_time_limit(0);

/* Turn on implicit output flushing so we see what we're getting
* as it comes in. */
ob_implicit_flush();

$address = '67.225.141.155';
$port = 10000;

if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
}

socket_close($sock);

if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
}


echo " socket";
echo $sock;

if (socket_bind($sock, '67.225.141.155', 3030) === false) {
echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}




echo " bin ed";
if (socket_listen($sock, 5) === false) {
echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}

do {
if (($msgsock = socket_accept($sock)) === false) {
echo "socket_accept() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
break;
}
/* Send instructions. */
$msg = "\nWelcome to the PHP Test Server. \n" .
"To quit, type 'quit'. To shut down the server type 'shutdown'.\n";
socket_write($msgsock, $msg, strlen($msg));

تشکر می کنیم.