4

My goal is to make a simple TCP proxy application for my test lab. I want to modify some JSON data on the fly. I successfully managed to work a TCP client, and a TCP server, but individually, not at once.

Basically I want a PHP with 2 sockets, one for incoming clients, one for outgoing to server, and forward data to each other.

1 Answer 1

3

Try Socket Programming With PHP and An Introduction to Sockets in PHP.

Both of those look like very good tutorials, in fact the first one appears to both recieve and send data.

EDIT: added Writing Socket Servers in PHP as that was the link that helped the OP.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for the answer! I've already looket at first tutorial, and now the second one. The fact, it does not involve client and server socket at the same time. Individually i succesfully wrote my app in client and server modes, but i need to bind a server socket, accept that connection, another socket that connects to a remote server. And when the client socket receives data, the server socket sends towards to server. And the reply from the server socket goes to client socket. I hope you got it :) Thanks.
Are you trying to write this as a webpage, or as a command line? Sockets really don't work well with web pages because the server WILL close the connection on you after a bit. Is Writing Socket Servers in PHP more what you need?
Of course, i have installed PHP 5.3 only, and running as a command line application :)
I missed the link in your comment. It's good for server well, but i need to implement a client too :) I tried before but data isnt tunnelled well though.
I tried to do with the tutorials, but the last one (Writing Socket Server in PHP) fails with error even with 1:1 copied code. Anyone who willing to help will greatly appreciated. Thanks :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.