Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 8th, 2006, 01:45 AM
bryan
Guest
 
Posts: n/a
Default Querying a HL Server

I'm trying to query a HL Server and return the "status" of it. I'm
unsure of how to do this exactly so I need some help, what I have so
far is as follows...
1. <?php
2. // Host / Port Settings:
3. $host = '70.86.248.86';
4. $socket = fsockopen('udp://' . $host, 27015, $errno, $errstr);
5. if ($socket) {
6. echo 'working';
7. if (fwrite($socket, 'status')) {
8. echo fread($socket, 128);
9. } else {
10. echo 'Problems writing';
11. }
12. } else {
13. echo 'not working';
14. }
15. ?>
Does anybody know how to do this properly or succeeded in doing this
before?
I am trying to query a counter-strike server and return the current
players/max players.

  #2  
Old August 8th, 2006, 02:45 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: Querying a HL Server

bryan wrote:
Quote:
I'm trying to query a HL Server and return the "status" of it. I'm
unsure of how to do this exactly so I need some help, what I have so
far is as follows...
1. <?php
2. // Host / Port Settings:
3. $host = '70.86.248.86';
4. $socket = fsockopen('udp://' . $host, 27015, $errno, $errstr);
5. if ($socket) {
6. echo 'working';
7. if (fwrite($socket, 'status')) {
8. echo fread($socket, 128);
9. } else {
10. echo 'Problems writing';
11. }
12. } else {
13. echo 'not working';
14. }
15. ?>
Does anybody know how to do this properly or succeeded in doing this
before?
I am trying to query a counter-strike server and return the current
players/max players.
>
Did you try asking the people running the server? They should know what
protocol you need to use.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #3  
Old August 11th, 2006, 03:05 PM
Adam
Guest
 
Posts: n/a
Default Re: Querying a HL Server

On 7 Aug 2006 17:49:08 -0700, bryan wrote:
Quote:
>I'm trying to query a HL Server and return the "status" of it. I'm
>unsure of how to do this exactly so I need some help, what I have so
>far is as follows...
1. <?php
2. // Host / Port Settings:
3. $host = '70.86.248.86';
4. $socket = fsockopen('udp://' . $host, 27015, $errno, $errstr);
5. if ($socket) {
6. echo 'working';
7. if (fwrite($socket, 'status')) {
8. echo fread($socket, 128);
9. } else {
10. echo 'Problems writing';
11. }
12. } else {
13. echo 'not working';
14. }
15. ?>
>Does anybody know how to do this properly or succeeded in doing this
>before?
>I am trying to query a counter-strike server and return the current
>players/max players.
My short answer is *don't bother*!

I tried for weeks to get sockets to behave for a similar application
(but for an online flight sim). It seems each incarnation of PHP
screws the sockets code around differently. After a fair while, I
found that some bugs reported in PHP3 are still there.

I also found differences in behaviour between Win32 and Unix/Linux
implementations of sockets. Don't be misled by the online function
references that make it look easy - I found that a fair few of the
routines just did not work consistently.

Also ... check you're getting past your firewall! I used a network
packet sniffer to see traffic actually leaving one machine then seeing
what (if anything) appeared on the other.

Adam.
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles