Jump to content

fsockopen


sanchez77

Recommended Posts

I am trying to open a Unix server and was wondering how would you return what the Unix server is saying, ie the prompt? Here is the code I was using after reading the php.net. The $call variable is my attempt at reading the server and have it return what it says.

 

I do have a connection to the server cause if I change the address or port number, i have the error in the log file saying the address refused the connection.

 

Any help/insight is really appreciated. Thanks

 


<?php

$host = "127.0.0.1";
$port = 9595;

$fp = stream_socket_client("tcp://".$host.":".$port."", $errno, $errstr, 30);

$call = fgets($fp);

echo $call;

fclose($fp);
?>


Link to comment
Share on other sites

sorry, code on the brain. It's really not fsockopen, it's stream_socket_client, but i tried fsockopen as well

 

<?php
$host = "127.0.0.1";
$port = 9595;

$fp = fsockopen($host, $port, $errno, $errstr, 30);

$call = fgets($fp);

echo $call;

fclose($fp);

?>

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.