473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

HTTP tunneling with PHP (prefereably PHP5)?

Is it possible (i.e. are there any modules out there) that allows one to
do HTTP tunneling from PHP? (Google is only bringing up ASP.NET links)

I'm working with PHP5 so ideally, the code is PHP5 (or at least OO).

tia

Jan 4 '06 #1
4 3473
NC
Paul Dodowa wrote:

Is it possible (i.e. are there any modules out there) that allows
one to do HTTP tunneling from PHP?
Yes. You will need to work with raw HTTP headers, however.
I'm working with PHP5 so ideally, the code is PHP5 (or
at least OO).


It's not that difficult. Basically, all you need to do is to establish
a connection with your proxy server using fsockopen() and then send a
CONNECT request... It's rather straightforward, so you can wrap it up
in all the OOP you want...

Cheers,
NC

Jan 4 '06 #2


NC wrote:
Paul Dodowa wrote:
Is it possible (i.e. are there any modules out there) that allows
one to do HTTP tunneling from PHP?

Yes. You will need to work with raw HTTP headers, however.

I'm working with PHP5 so ideally, the code is PHP5 (or
at least OO).

It's not that difficult. Basically, all you need to do is to establish
a connection with your proxy server using fsockopen() and then send a
CONNECT request... It's rather straightforward, so you can wrap it up
in all the OOP you want...

Cheers,
NC


Hi NC,

Have you got any good links/references that show how this is done?

Cheers mate

Jan 5 '06 #3
NC
Paul Dodowa wrote:
NC wrote:
It's not that difficult. Basically, all you need to do is to establish
a connection with your proxy server using fsockopen() and then send a
CONNECT request... It's rather straightforward, so you can wrap it up
in all the OOP you want...


Have you got any good links/references that show how this is done?


Let's say you want to connect to mail.example.com on port 25 through an
HTTP
tunnel using a proxy server called your.proxy.server:

$host = 'your.proxy.server';
$port = '4480'; // 4480 is the default HTTP proxy port
$fp = fsockopen($host, $port)
or die ("ERROR: Could not connect to proxy server $host on port
$port");
fputs($fp, "CONNECT mail.example.com:25 HTTP/1.0\r\n\r\n");
$response = '';
do {
$line = fgets($fp, 10240);
$response .= $line;
} while (trim($line) <> null);
// Now $response contains the complete response of mail.example.com.
// The response should be parsed to determine whether mail.example.com
// is ready to communicate. If it is, you can start sending requests
to
// mail.example.com using fputs() and read responses using fgets().
fclose ($fp);

Cheers,
NC

Jan 5 '06 #4


NC wrote:
Paul Dodowa wrote:
NC wrote:
It's not that difficult. Basically, all you need to do is to establish
a connection with your proxy server using fsockopen() and then send a
CONNECT request... It's rather straightforward, so you can wrap it up
in all the OOP you want...


Have you got any good links/references that show how this is done?

Let's say you want to connect to mail.example.com on port 25 through an
HTTP
tunnel using a proxy server called your.proxy.server:

$host = 'your.proxy.server';
$port = '4480'; // 4480 is the default HTTP proxy port
$fp = fsockopen($host, $port)
or die ("ERROR: Could not connect to proxy server $host on port
$port");
fputs($fp, "CONNECT mail.example.com:25 HTTP/1.0\r\n\r\n");
$response = '';
do {
$line = fgets($fp, 10240);
$response .= $line;
} while (trim($line) <> null);
// Now $response contains the complete response of mail.example.com.
// The response should be parsed to determine whether mail.example.com
// is ready to communicate. If it is, you can start sending requests
to
// mail.example.com using fputs() and read responses using fgets().
fclose ($fp);

Cheers,
NC

Thanks !

Jan 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Christoph Nothdurfter | last post by:
Hallo! I was wondering if my PHP4-Scripts will run under PHP5 (Haeven't tried the beta yet). Does anybody know? Thank you, -Christoph
8
by: Rob Ristroph | last post by:
I have tried out PHP 5 for the first time (with assistance from this group -- thanks!). The people I was working with have a site that uses lots of php objects. They are having problems with...
5
by: Tim Tyler | last post by:
I'm sure this is a FAQ - but I could not find a coherent statement of the answer: Some of my clients want PHP4. Other ones want PHP5. Can I run both PHP4 and PHP5 under the same instance of...
11
by: neur0maniak | last post by:
Hi, I've been eager to try out PHP5, so I've dumped it on my little dev machine. It's running WinXP with IIS5. I've put the php-cgi.exe in the "mappings" page as I'm used to doing with PHP4....
4
by: badbetty | last post by:
Dear Googlers I have installed PHP5 to run on WinXP against Apache 2. It works! ie. I have tested a few simple scripts and a basic xml document parse. I now want to try the XSL extension so I...
5
by: Aziz | last post by:
Hi, I've recently contacted technical service of a web hosting company and asked them wheter or not they're gonna upgrade to PHP5 and MySQL5. Here's a quote from their response which confused me...
3
by: DrLex | last post by:
It's hard to find a suitable forum for this question, but I suppose this should be one of the more appropriate ones. Mind that this is probably a pretty 'advanced' question ;) I have this...
3
by: xhe | last post by:
I have just upgraded my php version form php4 to php5. and I met this problem, and don't know if you know the solution. My site was written in PHP4, and most parts can be running smoothly in PHP5,...
2
by: mochinushi | last post by:
Im a newb C++ programmer trying to figure out what concepts and protocols i should be reading on... What im trying to accomplish is a "stealth" tunnel/forwarder from my computer at the dorm to a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.