Re: [PHP] Bind IP with fsockopen
On 4/12/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi ive tried \r\n\n and pretty much every other combination I can think of. But I still cant get it to return a line break. Otherwise the script is working though. A simple \r\n should do the job:) Tijnema - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 1:19 AM Subject: Re: [PHP] Bind IP with fsockopen fputs adds a newline, and you've got \r\n already, so your total output in the original is \r\n\n In the socket_bind one, you've got none of the \r\n stuff at all, much less \r\n\n On Tue, April 10, 2007 5:56 pm, [EMAIL PROTECTED] wrote: Im having trouble converting this snippet to use the bind_socket function. my original code is.. ? $domain = 'internet.co.uk'; $fs = fsockopen('dac.nic.uk', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); } else { fputs($fs, $domain\r\n); $line = fgets($fs, 1024); echo $line; } ? I think im getting stuck on the fputs bit.. I have this which does not work.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n; socket_write($sock, $request); //Read reply // Close socket_close($sock); ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bind IP with fsockopen
Thanks how would I handle the fgets line.. If I echo $sock I get resource ID #4 rather then the responce from the other computer. Before on my original script I returned the responce using fputs($fs, $domain\r\n); // send query $line = fgets($fs, 1024); // store reply echo $line; // output reply so far I have.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n\n; // send request socket_write($sock, $request); // store reply echo $sock; //output reply?? socket_close($sock); // Close ? - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 1:19 AM Subject: Re: [PHP] Bind IP with fsockopen fputs adds a newline, and you've got \r\n already, so your total output in the original is \r\n\n In the socket_bind one, you've got none of the \r\n stuff at all, much less \r\n\n On Tue, April 10, 2007 5:56 pm, [EMAIL PROTECTED] wrote: Im having trouble converting this snippet to use the bind_socket function. my original code is.. ? $domain = 'internet.co.uk'; $fs = fsockopen('dac.nic.uk', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); } else { fputs($fs, $domain\r\n); $line = fgets($fs, 1024); echo $line; } ? I think im getting stuck on the fputs bit.. I have this which does not work.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n; socket_write($sock, $request); //Read reply // Close socket_close($sock); ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bind IP with fsockopen
On 4/11/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Thanks how would I handle the fgets line.. http://www.php.net/socket_read If I echo $sock I get resource ID #4 rather then the responce from the other computer. Before on my original script I returned the responce using fputs($fs, $domain\r\n); // send query $line = fgets($fs, 1024); // store reply echo $line; // output reply so far I have.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n\n; // send request socket_write($sock, $request); // store reply echo $sock; //output reply?? socket_close($sock); // Close ? - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 1:19 AM Subject: Re: [PHP] Bind IP with fsockopen fputs adds a newline, and you've got \r\n already, so your total output in the original is \r\n\n In the socket_bind one, you've got none of the \r\n stuff at all, much less \r\n\n On Tue, April 10, 2007 5:56 pm, [EMAIL PROTECTED] wrote: Im having trouble converting this snippet to use the bind_socket function. my original code is.. ? $domain = 'internet.co.uk'; $fs = fsockopen('dac.nic.uk', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); } else { fputs($fs, $domain\r\n); $line = fgets($fs, 1024); echo $line; } ? I think im getting stuck on the fputs bit.. I have this which does not work.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n; socket_write($sock, $request); //Read reply // Close socket_close($sock); ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bind IP with fsockopen
Thanks Tijnema $line = trim(socket_read($sock, 1024)); was what I was after. Thanks - Original Message - From: Tijnema ! [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Wednesday, April 11, 2007 5:09 PM Subject: Re: [PHP] Bind IP with fsockopen On 4/11/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Thanks how would I handle the fgets line.. http://www.php.net/socket_read If I echo $sock I get resource ID #4 rather then the responce from the other computer. Before on my original script I returned the responce using fputs($fs, $domain\r\n); // send query $line = fgets($fs, 1024); // store reply echo $line; // output reply so far I have.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n\n; // send request socket_write($sock, $request); // store reply echo $sock; //output reply?? socket_close($sock); // Close ? - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 1:19 AM Subject: Re: [PHP] Bind IP with fsockopen fputs adds a newline, and you've got \r\n already, so your total output in the original is \r\n\n In the socket_bind one, you've got none of the \r\n stuff at all, much less \r\n\n On Tue, April 10, 2007 5:56 pm, [EMAIL PROTECTED] wrote: Im having trouble converting this snippet to use the bind_socket function. my original code is.. ? $domain = 'internet.co.uk'; $fs = fsockopen('dac.nic.uk', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); } else { fputs($fs, $domain\r\n); $line = fgets($fs, 1024); echo $line; } ? I think im getting stuck on the fputs bit.. I have this which does not work.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n; socket_write($sock, $request); //Read reply // Close socket_close($sock); ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bind IP with fsockopen
Hi ive tried \r\n\n and pretty much every other combination I can think of. But I still cant get it to return a line break. Otherwise the script is working though. - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 1:19 AM Subject: Re: [PHP] Bind IP with fsockopen fputs adds a newline, and you've got \r\n already, so your total output in the original is \r\n\n In the socket_bind one, you've got none of the \r\n stuff at all, much less \r\n\n On Tue, April 10, 2007 5:56 pm, [EMAIL PROTECTED] wrote: Im having trouble converting this snippet to use the bind_socket function. my original code is.. ? $domain = 'internet.co.uk'; $fs = fsockopen('dac.nic.uk', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); } else { fputs($fs, $domain\r\n); $line = fgets($fs, 1024); echo $line; } ? I think im getting stuck on the fputs bit.. I have this which does not work.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n; socket_write($sock, $request); //Read reply // Close socket_close($sock); ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bind IP with fsockopen
Im having trouble converting this snippet to use the bind_socket function. my original code is.. ? $domain = 'internet.co.uk'; $fs = fsockopen('dac.nic.uk', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); } else { fputs($fs, $domain\r\n); $line = fgets($fs, 1024); echo $line; } ? I think im getting stuck on the fputs bit.. I have this which does not work.. ?php $domain = 'internet.co.uk'; $sourceip = 'xx.xx.xx.xx'; // ip you want to bind to $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $sourceip); socket_connect($sock, 'dac.nic.uk', 2043); // Write $request = $domain\r\n; socket_write($sock, $request); //Read reply // Close socket_close($sock); ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Bind IP with fsockopen
Hi is it possible to socket_bind with fsockopen? im using this with all my scripts... $fs = fsockopen('example.com', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); and I need the remote conection to see me as one of my other IP's Ive read through socket_bind http://uk.php.net/manual/en/function.socket-bind.php but cant see how to use it with my above code Thanks
Re: [PHP] Bind IP with fsockopen
On 4/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi is it possible to socket_bind with fsockopen? im using this with all my scripts... $fs = fsockopen('example.com', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); and I need the remote conection to see me as one of my other IP's Ive read through socket_bind http://uk.php.net/manual/en/function.socket-bind.php but cant see how to use it with my above code Thanks I'm not sure if it's possible, it depends on the setup of switches etc. You're remote connection is outside your LAN right? If so, then your IP address is assigned by your ISP, this is assigned for each connection. I guess you have more then one connection from your ISP, then you have more then one IP. So if you have more then one connection, you have more then one modem/router. So if you want to use the IP of another connection, you should connect through another router/modem. But this depends on your setup, and has nothing to do with PHP. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bind IP with fsockopen
I have a dedicated server with a number of IP addresses. When you make a connection through fsockopen it connects using the servers main IP address. What I want to do is specify which of my IP addresses fsockopen uses. Thanks - Original Message - From: Tijnema ! [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Saturday, April 07, 2007 11:54 PM Subject: Re: [PHP] Bind IP with fsockopen On 4/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi is it possible to socket_bind with fsockopen? im using this with all my scripts... $fs = fsockopen('example.com', 2043, $errno, $errstr, 60); if (!$fs) { fclose($fs); and I need the remote conection to see me as one of my other IP's Ive read through socket_bind http://uk.php.net/manual/en/function.socket-bind.php but cant see how to use it with my above code Thanks I'm not sure if it's possible, it depends on the setup of switches etc. You're remote connection is outside your LAN right? If so, then your IP address is assigned by your ISP, this is assigned for each connection. I guess you have more then one connection from your ISP, then you have more then one IP. So if you have more then one connection, you have more then one modem/router. So if you want to use the IP of another connection, you should connect through another router/modem. But this depends on your setup, and has nothing to do with PHP. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bind IP with fsockopen
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
Re[2]: [PHP] Bind IP with fsockopen
Hi, TR You will have to do it using the socket api something like this but TR with error checking: TR ?php TR $sourceip = '192.168.1.1'; // ip you want to bind to TR $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); TR socket_bind($sock, $sourceip); TR socket_connect($sock, 'example.com', 2043); TR // Write TR $request = 'GET / HTTP/1.1'.\r\n.'Host: example.com'.\r\n\r\n; TR socket_write($sock, $request); TR //Read reply TR // Close TR socket_close($sock); Another option using streams (php5): ?php $opts = array( 'socket'=array( 'bindto'='192.168.1.1:0' //any port will do ) ); $context = stream_context_create($opts); $html = file_get_contents('http://example.com:2043', false, $context); -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php