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
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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.