[QUESTION] SAMP Query PHP Script
#1

Summary: I've been trying to use the sockets code from the sa-mp query script and for some reason it won't work.
PHP код:
$fp = @fsockopen('udp://'.DB_SERVER7777$errno$errstr0.05);
if(!
$fp) echo 'Offline';
else echo 
'Online'close($fp); 
Info: DB_SERVER is a DNS (EX: xxx.gotdns.com)
Problem: No matter what status the server has (online/offline) it only echoes 'Online'.

Anyone here that might tell me what is wrong?
PS: Just started working with sockets...
Reply
#2

UDP is basically a connectionless protocol. You fire packets at it, and you don't know what the outcome is.

You need to send a ping packet and compare the response. Here's an example, check __construct().
Reply
#3

I've looked at your code, it's very interesting, but I have a question:
If I use your method, would it delay the creation of an image through php? Talking about imagecreatefrompng();
Reply
#4

Quote:
Originally Posted by viKKmaN
Посмотреть сообщение
I've looked at your code, it's very interesting, but i have a question:
If i use your method, would it delay the creation of an image through php? Talking about imagecreatefrompng();
I guess both methods would a bit
but I don't think theres a big delay

but also I guess it depends on the speed the packets are sent back..
Reply
#5

Thanks for the advice, for now I am going to query a table in the database created by server to check it's status, but only until I grasp the concept of sockets and packets.
Reply
#6

Quote:
Originally Posted by viKKmaN
Посмотреть сообщение
Thanks for the advice, for now I am going to query a table in the database created by server to check it's status, but only until I grasp the concept of sockets and packets.
another advise
if it isn'T for learningreasons what you are doing
I'd use westies query system
its easier and faster that way
also its very secure^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)