SA-MP Forums Archive
[QUESTION] SAMP Query PHP Script - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: [QUESTION] SAMP Query PHP Script (/showthread.php?tid=224736)



[QUESTION] SAMP Query PHP Script - viKKmaN - 12.02.2011

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...


Re: [QUESTION] SAMP Query PHP Script - Westie - 12.02.2011

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().


Re: [QUESTION] SAMP Query PHP Script - viKKmaN - 12.02.2011

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();


Re: [QUESTION] SAMP Query PHP Script - saiberfun - 12.02.2011

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..


Re: [QUESTION] SAMP Query PHP Script - viKKmaN - 12.02.2011

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.


Re: [QUESTION] SAMP Query PHP Script - saiberfun - 12.02.2011

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^^