Jump to content

Socket Isn't Connecting


Lamaboy

Recommended Posts

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

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.