-1

This is my code:

$socketConnection = @fsockopen ( "127.0.0.1", "23", $errorNumber, $errorString, 30 );
if ( ! $socketConnection )
{
    print '<b>Connection Failed</b><br />' . $errorString . '<br />' . $errorNumber;
}
else
{
    //stream_set_blocking ( $socketConnection, 0 );
    //stream_set_timeout ( $socketConnection, 10 );
    print '<b>Connection Success!</b><br />';
    fputs($socketConnection,'\r');
    sleep(1);
    $buffer = fread ( $socketConnection, 20 );
    $out='';
    for ( $i=0; $i < 20; $i++ )
    {
        $out .= $buffer [ $i ] ;
    }
        $response = trim ( preg_replace( "/^.*?\n(.*)\n[^\n]*$/", "$1", $out ) );
        echo $response;
        //$response = bin2hex($response);
        //hex2ascii('ff:fd:25:ff:fb:01:ff:fb:03:ff:fd:27:ff:fd:1f:ff:fd:00:ff:fb');
    fclose ( $socketConnection );
}

Now, when i execute the code, I get the output:

ÿý%ÿûÿûÿý'ÿýÿý

and nothing else. What can be the problem? And how can I get this problem cleared. I am on win7 with xampp version 2.5

Moreover, I installed win7 telnet server on my system and I can telnet it from telnet command.

I used putty to telnet and here is what i got: putty login screenshot

Assad Nazar
  • 1,420
  • 5
  • 20
  • 40

1 Answers1

0

It's a part of the "auto-negotiation" for telnet clients...

It will help if you convert the characters to HEX, and then reference:

The TELNET Protocol -- KB 231866

Oh, and even though you said Microsoft, :

www.eventhelix.com - EventStudio - TCP/IP Protocol Sequence Diagram Examples

Specifically, these may help you visualize:

High-level Telnet Client and Server Protocol Sequence Diagram

Telnet Protocol Context Diagram -- EventHelix.com/EventStudio 2.0

Which you can find on the eventhelix.com page.

(Note: sorry for no links on the last two..., my rep is still too low on here... ;-)

Community
  • 1
  • 1
George 2.0 Hope
  • 583
  • 1
  • 6
  • 21