Jump to content

converting perl socket to php


rgren925

Recommended Posts

Hi.

I've tried just about everything I can think of, but no success.

 

Here's the perl I'm trying to convert:

 

$socket = new IO::Socket::INET ( PeerAddr => 'localhost', PeerPort => 1500, Proto => 'tcp');

if ($socket->send("$token\n")) {

    $data = <$socket>;

}

 

Here's what I've currently got in PHP:

 

$socket = fsockopen('localhost', 1500, $errno, $errstr);

fwrite($socket, "$token\n");

$data = fread($socket, 1024);

fclose($socket);

 

I've confirmed the socket descriptor is populated and the fwrite is working.

The fread just hangs.

I've tried fputs/fgets in various combinations, but the read/get always hangs.

 

Any ideas?

 

Thanks very much,

Rick

Link to comment
https://forums.phpfreaks.com/topic/230297-converting-perl-socket-to-php/
Share on other sites

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.