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 Link to comment https://forums.phpfreaks.com/topic/188538-socket-isnt-connecting/ 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). Link to comment https://forums.phpfreaks.com/topic/188538-socket-isnt-connecting/#findComment-995354 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 Link to comment https://forums.phpfreaks.com/topic/188538-socket-isnt-connecting/#findComment-995357 Share on other sites More sharing options...
Lamaboy Posted January 15, 2010 Author Share Posted January 15, 2010 Any ideas on this? Thanks. Link to comment https://forums.phpfreaks.com/topic/188538-socket-isnt-connecting/#findComment-995865 Share on other sites More sharing options...
Felex Posted January 15, 2010 Share Posted January 15, 2010 does $errstr gives the same information ? Link to comment https://forums.phpfreaks.com/topic/188538-socket-isnt-connecting/#findComment-995881 Share on other sites More sharing options...
Lamaboy Posted January 15, 2010 Author Share Posted January 15, 2010 Basically. It reads "Connection timed out" Link to comment https://forums.phpfreaks.com/topic/188538-socket-isnt-connecting/#findComment-995890 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. Link to comment https://forums.phpfreaks.com/topic/188538-socket-isnt-connecting/#findComment-995892 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! Link to comment https://forums.phpfreaks.com/topic/188538-socket-isnt-connecting/#findComment-996974 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.