Re: Bind IP with fsockopen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Sunday, April 8, 2007, 6:51:46 AM, you wrote:
cac> Hi is it possible to socket_bind with fsockopen? im using this with all my scripts...

cac> $fs = fsockopen('example.com', 2043, $errno, $errstr, 60);
cac> if (!$fs) {
cac> fclose($fs);

cac> and I need the remote conection to see me as one of my other IP's

cac> Ive read through socket_bind
cac> http://uk.php.net/manual/en/function.socket-bind.php

cac> but cant see how to use it with my above code

cac> Thanks

You will have to do it using the socket api something like this but
with error checking:

<?php
$sourceip = '192.168.1.1'; // ip you want to bind to
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($sock, $sourceip);
socket_connect($sock, 'example.com', 2043);
// Write
$request = 'GET / HTTP/1.1'."\r\n".'Host: example.com'."\r\n\r\n";
socket_write($sock, $request);
//Read reply
// Close
socket_close($sock);

?> 


-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux