Page 1 of 1

PHP Proxy Help (Not HTTP)

Posted: Thu Feb 08, 2007 8:28 am
by alluran
Hey, Am looking to attempt a php proxy again.
Last time i did it the script would stop and pause every time there was no data coming in from a port so I was hoping for a few pointers and/or examples/snippets before i get started on trying this again.

The proxy has to be able to stream data two ways, and process the data on the way, without needing to wait at any time for data to arrive at a port.

Thanks for any tips.

Alluran

Posted: Thu Feb 08, 2007 9:08 am
by Mordred
Seeing that this is the first post of this user, "again" is not much of an explanation ;) Explain what do you mean by "PHP proxy, but not HTTP". I have written a HTTP proxy server in PHP using the socket API, but it seems like you don't exactly mean that.
Maybe it's about a web-proxy that accepts requests through a web interface, but then how would you go on "stream(ing) data two ways"?

Posted: Thu Feb 08, 2007 5:41 pm
by alluran
Yeah, last time i went solo, didn't use any forums etc, basically, i'm trying to build a proxy for the MUD i play, where I can act upon the data coming in and out before it reaches the MUD / client

EG

Client Application <--> PHP Proxy <--> MUD Server

But last time i did this, it would wait for data to arrive from the mud server, then send that on to the client, then wait for the client to reply, then send to the server, etc. I don't want it to wait, If there's data in the buffer, read it in, act on it, then pass it to the opposite socket to send out, otherwise, check the other buffer (continual loop, this isn't a web-based proxy, it'd be a command-line based one)

Posted: Fri Feb 09, 2007 3:07 am
by Mordred
Ah, got it, you want a generic TCP proxy for a custom (MUD) protocol.
I suggest you try a "visual" language like Delphi or the likes, you can build the proxy with a couple of controls and a couple of lines of code.

If you need to do it in PHP, you have to code a bit more ;) This means that the proxy will be a script that runs continuously, opens a server and a client socket and forwards traffic between them after rewriting it.

If your project is GPL-compatible, you can see my Philtron project (now in hiatus) here: http://philtron.sourceforge.net/
Otherwise, you are allowed to read the source only as an inspiration, but not to copy it!

Posted: Fri Feb 09, 2007 6:08 am
by timvw
Why do you want to use php in the first place? Imho there are environments more suited to implement a tcp proxy..