----- Original Message ----- 
From: "Waqas Habib"

Thanks. I am giving you my specification with an example.
  Suppose i want to send 7-Bytes to a socket. I want to put "1" in first 
byte, "0" in second byte, "3" in 3rd byte, and an IP address in remaining 
bytes. How can i do it? And also its reverse process.
  Hope you understand the problem..

  -Waqas

------------------------------------

<?php

$byte[0] = 1;
$byte[1] = 0;
$byte[2] = 3;
$ip = '123.045.067.089';
for($count = 0; $count < 4; $count++)
  {
  $byte[$count + 3] = intval(substr($ip, $count * 4, 3));
  }
$output = '';
foreach($byte as $onesbyte)
  {
  $output .= chr($onebyte);
  }

$remote_ip = '98.76.54.32';
$remote_port = 1234;

$fh = fsockopen('http://' . $remote_ip, $remote_port, $errno, $errstr);
if (!$fh)
  {
  echo( "$errstr ($errno)<br>\n");
  die();
  }
fputs($fh, $output);
fclose($fh);

?>

I am not sure what you mean by "reverse process". The above is outgoing 
connection and outgoing data.

Do you mean ???
1) Outgoing connection, incoming data?
2) Incoming connection, outgoing data?
3) Icoming connection, incoming data?

Robert. 

Reply via email to