XUnreal
New Member
- Messages
- 370
- Reaction score
- 0
- Points
- 0
I have had a problem trying to make a PHP Socket. The code is below:
NedreN would probably know the answer but if anyone else knows PLEASE reply.
Thanks in advance,
- dphiance.
NOTE: Sorry about that other post, I accidently pressed Tab then Enter before I finished the post... Please delete the old post.
PHP:
<?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 = '{REMOVED}';
$port = 551;
if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror($sock) . "\n";
}
if (($ret = socket_bind($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror($ret) . "\n";
}
if (($ret = socket_listen($sock, 5)) < 0) {
echo "socket_listen() failed: reason: " . socket_strerror($ret) . "\n";
}
do {
if (($msgsock = socket_accept($sock)) < 0) {
echo "socket_accept() failed: reason: " . socket_strerror($msgsock) . "\n";
break;
}
do {
explode(" ", $buf)
if ($buf[0] == "LVER") {
$lver = "0.1"
if ($buf[1] < $lver) {
socket_write($msgsock, "OLD", "3");
}
if ($buf[1] > $lver) {
socket_write($msgsock, "NEW", "3");
}
if ($buf[1] == $lver) {
socket_write($msgsock, "NEW", "3");
}
}
}
if (false === ($buf = socket_read($msgsock, "550", PHP_NORMAL_READ))) {
echo "socket_read() failed: reason: " . socket_strerror($ret) . "\n";
break 2;
}
if (!$buf = trim($buf)) {
continue;
}
if ($buf == 'quit') {
break;
}
if ($password == '{REMOVED}') {
socket_close($msgsock);
break 2;
}
} while (true);
socket_close($msgsock);
} while (true);
socket_close($sock);
?>
Thanks in advance,
- dphiance.
NOTE: Sorry about that other post, I accidently pressed Tab then Enter before I finished the post... Please delete the old post.
Last edited: