[EMAIL PROTECTED] wrote:          ----- 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. 
   
  ------------------------------------------------------------
   
  Thanks.

 From reverce process i mean that if i have to read 25, 26, or 15
bytes from that socket, with same type of arrangements i-e suppose 4
bytes for IP address, remaining bytes for simple data i-e 0;

 Please if you can write example code for this process also (like
you have write for writing on socket).

   -Waqas




                           

       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.

[Non-text portions of this message have been removed]

Reply via email to