fsockopen ??

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

Post Reply
CSL126
Forum Newbie
Posts: 3
Joined: Tue Aug 03, 2004 9:37 pm

fsockopen ??

Post by CSL126 »

Hey guys, I was wondering if anyone could write me a short script. I just want to simply check to see if a server is running. I was told to use fsockopen() on a different forum, but I could never figure out how to get it to work. It works when the server is online, but when it is offline, it throws me a bunch of errors and warnings. How can I get rid of those, and just simply display "server is offline" ?? Thanks in advance!
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Add a @ to the beginning of the function call:

Code: Select all

@fsockopen("domain");
Last edited by nigma on Tue Aug 03, 2004 9:58 pm, edited 2 times in total.
CSL126
Forum Newbie
Posts: 3
Joined: Tue Aug 03, 2004 9:37 pm

Post by CSL126 »

Ok, cool i'll try that out... Thanks a lot!
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Let me know how things turn out.
CSL126
Forum Newbie
Posts: 3
Joined: Tue Aug 03, 2004 9:37 pm

Post by CSL126 »

Works great! what exactly does the "@" symbol do when it's in front of fsockopen() though?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it suppresses any error that may get output.. say the domain doesn't respond or something..
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

You know, I asked the same question a few months ago, I knew it somehow suppressed errors, but I wasn't sure if it was supposed to do that or if it was just a hack.

Let me do some searching and try to find my post.
Post Reply