关于SOCKET的问题,如何安装socket server,如何启动 socket server,具体的配置是怎么样的?
关于SOCKET的问题,如何安装socket server,如何启动 socket server,具体的配置是怎么样的?
我现在是在windows 2000上,iis,php_sockets.dll和php_w32api.dll加载了
其他还要注意什么呢?
<?php
/*
* We don't want any time-limit for how the long can hang
* around, waiting for connections:
*/
set_time_limit(0);
/* Create a new socket: */
if( ($sock = socket( AF_INET, SOCK_STREAM, 0 )) < 0 )
{
print strerror( $sock ) . "\n";
exit(1);
}
/* Bind the socket to an address and a port: */
if( ($ret = bind( $sock, "10.31.172.77", 10000 )) < 0 )
{
print strerror( $ret ) . "\n";
exit(1);
}
/*
* Listen for incoming connections on $sock.
* The '5' means that we allow 5 queued connections.
*/
if( ($ret = listen( $sock, 5 )) < 0 )
{
print strerror( $ret ) . "\n";
}
/* Accept incoming connections: */
if( ($msgsock = accept_connect( $sock )) < 0)
{
print strerror( $msgsock ) . "\n";
exit(1);
}
/* Send the welcome-message: */
$message = "Welcome to my TCP-server!\n";
if( ($ret = write( $msgsock, $message, strlen($message)) ) < 0 )
{
print strerror( $msgsock ) . "\n";
exit(1);
}
/* Read/Receive some data from the client: */
$buf = '';
if( ($ret = read( $msgsock, $buf, 128 )) < 0 )
{
print strerror( $ret ) . "\n";
exit(1);
}
/* Echo the received data back to the client: */
if( ($ret = write( $msgsock, "You said: $buf{CONTENT}\n", strlen("You said: $buf{CONTENT}\n")) ) < 0 )
{
print strerror( $ret ) . "\n";
exit(1);
}
/* Close the communication-socket: */
close( $msgsock );
/* Close the global socket: */
close( $sock );
?>
出错信息:
Call to undefined function: socket()
请大虾帮忙,谢谢!