PHP Proxy Help (Not HTTP)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alluran
Forum Newbie
Posts: 2
Joined: Thu Feb 08, 2007 7:35 am

PHP Proxy Help (Not HTTP)

Post 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
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post 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"?
alluran
Forum Newbie
Posts: 2
Joined: Thu Feb 08, 2007 7:35 am

Post 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)
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post 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!
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Why do you want to use php in the first place? Imho there are environments more suited to implement a tcp proxy..
Post Reply