10 Years of Service
64%
Please note, if you want to make a deal with this user, that it is blocked.
PHP Client:
Code:
><?php
$host = "201.41.170.212";
$port = 5110; // nat opened port
$timeout = 6000;
$sk = fsockopen($host,$port,$errnum,$errstr,$timeout);
if (!is_resource($sk)) {
exit("connection fail: ".$errnum." ".$errstr);
} else {
fputs($sk, "hello world");
$dati = "";
while (!feof($sk)) {
$dati.= fgets ($sk, 1024);
}
}
fclose($sk);
echo($dati);
?>
Autoit Server:
Code:
>#include "TCP.au3"
TrayTip("SERVER","Creating server...",10,1)
$hServer = _TCP_Server_Create(5110)
sleep(1000)
TrayTip(";SERVER","Server is runnning...",30)
_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received
_TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server.
_TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects.
While 1
Sleep(10)
WEnd
Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received.
TrayTip("SERVER", "We received this: "& $sReceived, 30); (and we'll display it)
EndFunc
Func NewClient($hSocket, $iError); Yo, check this out! It's a $iError parameter! (In case you didn't noticed: It's in every function)
TrayTip("SERVER","New client connected."&@CRLF&"Sending this: Bleh!",30)
; send something
_TCP_Send($hSocket, "Bleh!")
EndFunc
; client lost
Func Disconnect($hSocket, $iError)
TrayTip("SERVER","Client disconnected.",30)
EndFunc