Lamaboy Posted January 15, 2010 Share Posted January 15, 2010 Hi. I'm using the following code to connect through PHP to a visual basic socket. <?php $server = "gameserver.no-ip.org"; $port = "6544"; // TO GET THE ERROR MESSAGE $errstr = ""; // TO GET THE ERROR NUMBER $errno = ""; // TIME OUT AFTER $timeout = "25"; $Check = ""; // NOW CHECK THE PORT/IP $Check = @pfsockopen($server, $port, $errno, $errstr, $timeout); // NOW SEE IF IT WAS OK OR NOT if ($Check) { echo "<img src='http://www.example.net/images/online.png'>"; } else { echo "<img src='http://www.example.net/images/offline.png'>"; } ?> A friend wrote this code for me, but I haven't been able to find him to ask about it. Basically, if I go in a web browser to the IP and port, (I.e. 192.168.1.1:1111) it will connect with the visual basic socket and I can then send information and such. However for some reason, the PHP code isn't connecting to the Visual Basic socket, and I can't even see the connection request. Anyone have any ideas with this code? Thanks very much, Lamaboy Quote Link to comment Share on other sites More sharing options...
trq Posted January 15, 2010 Share Posted January 15, 2010 Remove the @ so you might see what is actually happening. (Make sure error reporting and display errors is on also). Quote Link to comment Share on other sites More sharing options...
Lamaboy Posted January 15, 2010 Author Share Posted January 15, 2010 Warning: pfsockopen() [function.pfsockopen]: unable to connect to Ipremoved:6544 (Connection timed out) in adressremoved on line 16 Quote Link to comment Share on other sites More sharing options...
Lamaboy Posted January 15, 2010 Author Share Posted January 15, 2010 Any ideas on this? Thanks. Quote Link to comment Share on other sites More sharing options...
Felex Posted January 15, 2010 Share Posted January 15, 2010 does $errstr gives the same information ? Quote Link to comment Share on other sites More sharing options...
Lamaboy Posted January 15, 2010 Author Share Posted January 15, 2010 Basically. It reads "Connection timed out" Quote Link to comment Share on other sites More sharing options...
Felex Posted January 16, 2010 Share Posted January 16, 2010 are you sure that port is open and host is running ? Your code is so simple and free of errors as i see. there must be something different. Quote Link to comment Share on other sites More sharing options...
Lamaboy Posted January 18, 2010 Author Share Posted January 18, 2010 are you sure that port is open and host is running ? Your code is so simple and free of errors as i see. there must be something different. Yes, because like I said, I can type http:\\ipadress:port into a browser and it will connect to the host, but the php page won't! I don't understand it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.