PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Revan
Forum Commoner
Posts: 83 Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:
Post
by Revan » Tue Aug 03, 2004 3:50 am
Hello, im running HLStats, and im making a script that prints weither its up or not
I was thinking some thing like
Code: Select all
$stat_dameon = fsockopen("udp://127.0.0.1","27500");
if ( $stat_dameon ) {
print "Online";
} elseif ( !$stat_dameon ) {
print "Offline";
}
but it doesnt work, any ideas?
kettle_drum
DevNet Resident
Posts: 1150 Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England
Post
by kettle_drum » Tue Aug 03, 2004 5:20 am
Try adding the other parameters to the fsockopen.
Code: Select all
$stat_dameon = fsockopen("127.0.0.1","27500", &$err_num, &$err_msg, 30);
if ( $stat_dameon ) {
print "Online";
} elseif ( !$stat_dameon ) {
print "Offline";
}
fresh
Forum Contributor
Posts: 259 Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika
Post
by fresh » Tue Aug 03, 2004 6:02 am
thats awesome, you can do that stuff with PHP??
what a great friggin language
Revan
Forum Commoner
Posts: 83 Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:
Post
by Revan » Tue Aug 03, 2004 6:29 am
fresh wrote: thats awesome, you can do that stuff with PHP??
what a great friggin language
Yes, PHP is the best
first time working with socks
@kettle_drum
that didnt work :/
btw its a UDP port so i tryed doing
Code: Select all
<?php
$stat_dameon2 = fputs($stat_dameon,"test");
?>
but it still says its online
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Tue Aug 03, 2004 6:50 am
Revan
Forum Commoner
Posts: 83 Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:
Post
by Revan » Tue Aug 03, 2004 12:01 pm
Don't think so, absul suck with classes
the problem im having is fsockopen doesnt return that it connected or failed, iit returns a process ID
Revan
Forum Commoner
Posts: 83 Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:
Post
by Revan » Tue Aug 03, 2004 4:42 pm
In the end i used this
Code: Select all
<?php
$socket_hlstats_daemon = @socket_create(AF_INET,SOCK_DGRAM,SOL_UDP);
$stat_dameon = @socket_bind($socket_hlstats_daemon , "127.0.0.1", 27500);
if ( $stat_dameon ) {
print "Offline";
} else {
print "Online";
}
@socket_close($socket_hlstats_daemon);
?>
Gave up on fsocket
Thanks for trying guys