Advertisement

Detecting my Server on my Website

Started by November 26, 2003 05:44 PM
15 comments, last by RonHiler 21 years, 2 months ago
This is gamedev.net...I have to always be on my guard I''m so used to people slamming everything that I say that it has become nearly automatic to instantly defend my knowledge. Gotta love this place...

Anyways, sounded to me like you were gung-ho on starting another infamous language-war. Nothing in your post had to do with the thread itself and so I assumed the obvious. Maybe it''s just me though I doubt it

synth0id
There is no point in doing anything at all, you'll die pretty soon anyway.
RonHiler:
if you are interested i could give you some more details as this is just a quite old piece of code not really showing what the games does.
http://mitglied.lycos.de/lousyphreak/
Advertisement
No need, I don''t think LP. I used a variation on your code snippet from my website, and my server picked it up! Just like it would a regular packet from one of the clients. Very cool!

It doesn''t yet know what to do with the packet, so it''s complaining about an unknown packet type, but that''s just because I haven''t coded it into the server code yet. I get the same thing whenever I code a new packet into the clients.

I''ll try responding with the population data and see if the web site server gets it back. I don''t see why it wouldn''t, though. It seems like this might work fine! Yay If I have any problems I''ll probably ask for further help, but I think I''ve got it from here.

Thanks a lot for the advice guys, this will be a very cool addition to my site.

-Ron
Creation is an act of sheer will
I got so *very* close!

Unfortunately, I ran into a snag. LP, or anyone, perhaps you can tell me what I'm doing wrong. Unfortunately, these socket functions are "experimental" and therefore documentation seems to be pretty non-existant.

Anyway, the website sends a packet and the server, if it's up and running, sends a response of two ints (basically the Launcher population and the Client population). This gets back to the web server, where it seems to get there okay (the result of socket_recvfrom is 8, the number of bytes I sent from the server). But my recieve buffer seems to be empty!

Here is the php code (I'm taking out my server address and port, in the actual code they are there):

<?phpif(($sock = socket_create (AF_INET, SOCK_DGRAM, 0)) < 0)    {      echo "socket_create() failed: reason: " . socket_strerror($sock) . "<BR>";    }    else  {  $server='xxx.xxx.xxx.xxx';  $port=yyyy;  $send=sprintf('%c%c%c%c',24, 0, 0, 0);  $x=socket_sendto($sock,$send,strlen($send)-1,0,$server,$port);    //don't allow blocking, do a 3 second timeout  //if we don't get a response by 3 seconds, the server probably ain't there...  $bar = array($sock);  $select_result = socket_select($bar, $b=null, $c=null, 3);  if ($select_result == true)    {    $y=socket_recvfrom($sock,&$recvbuf,1024,0,&$from,&$port);    //temporary var loading, let's just see what we get first...    $LauncherPopulation = sprintf('%d',$recvbuf[0]);    $ClientPopulation = sprintf('%d',$recvbuf[4]);    //check the results    echo $recvbuf . $y . "<BR>"; //($y = 8, $recvbuf has no output??)    echo "Launcher Population:" . $LauncherPopulation . "<BR>";    echo "Client Population:" . $ClientPopulation . "<BR><BR>";    //both population variables report 0, even when players in game????    }  else    {    echo "Server Timeout<BR><BR>";    }  }socket_close($sock);?>


As I said, this works fine for detecting if the server is running or not, (the if statement goes through the true or false path depending on the server status). I just can't seem to pull those 8 bytes I've received out into variables. Any suggestions?


[edited by - RonHiler on November 29, 2003 4:20:26 PM]

[edited by - RonHiler on November 29, 2003 5:24:16 PM]
Creation is an act of sheer will
I got it. It turns out that socket_recvfrom() can''t deal with binary data, only alpha-numberic text. So I turned the population data into strings at the server end and passed them that way, and everything works great now.
Creation is an act of sheer will
now as you mention it i remember the exact same problem back when i was coding it (yea its *really* old )

they should've fixed it by now....

edit:
just checked - this bug is gone (php 4.3.3 linux)

actually its almost a year dead by now. what php version are you using?

[edited by - LousyPhreak on December 1, 2003 12:57:08 PM]
http://mitglied.lycos.de/lousyphreak/
Advertisement
Looks like I have php 4.2.3 on my web server. It has a build date of Jan 8 2003. So perhaps it wasn''t fixed yet in that version. I have no control over the php version installed, that''s the web people''s deal. I suppose I could ask them to update it, but eh, I already programmed a workaround, and I don''t code on my website enough to lose sleep over it

Creation is an act of sheer will

This topic is closed to new replies.

Advertisement