reactphp / socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.
https://reactphp.org/socket/
MIT License
1.2k stars 156 forks source link

New to reactphp : I think my problem is easy for you #294

Closed sktechnology closed 2 years ago

sktechnology commented 2 years ago

Hi, my miner is connecting to the port 8080, i just want to forward all tcp communication to my stratum on the port 3500, i want to see the communication.

I have read the documentation but my english is not very good i am french..

I have opened socketserver on the port 8080 and the miner is connecting to the stratum but i think i dont receive response back from.

this is my code, thx you for your help

$socket = new React\Socket\SocketServer('192.168.1.147:8080'); $connector = new React\Socket\Connector();

$socket->on('connection', function (React\Socket\ConnectionInterface $connection) {

 $connection->on('data', function ($data) use ($connection) {

     echo $data;
     $connection->write($data);

});

});

$connector->connect('192.168.1.147:3500')->then(function (React\Socket\ConnectionInterface $connection) {

     $connection->on('data', function ($data) use ($connection) {

     echo $data;
     $connection->write($data);

});

});

SimonFrings commented 2 years ago

Hey @sktechnology, thanks for bringing this up :+1:

I am not 100% sure what you're trying to achieve here. Maybe take a look at reactphp/http or clue/reactphp-http-proxy if you're using HTTP. You can also post your question at stackoverflow for more help.

I hope this helps as a starting point. If this is not the case, you can provide us some more information about your use case and your code input and the output you're receiving.

sktechnology commented 2 years ago

Hi @SimonFrings thx for your reply, i try to make communication beetween 2 socket. 1 socket is the server and waiting for connection when the connection is done the data need to be transfered to the second socket this socket connect to another port. the connexion is done by TCP, I dont know if i can use http for handle the data.

clue commented 2 years ago

@sktechnology Hi and welcome to @ReactPHP!

Your question is very broad at the moment, so I can only assume you're looking for the pipe() method to forward data from one connection to another connection in some kind of application that resembles a proxy server. If you can ask more specific questions, I'm sure this is something we can help with, but as it stands answering your question pretty much entails implementing your entire project. I also provide professional support, so I invite you to check out my profile if you're interested, but I'm sure you understand that this is somewhat out of scope for this issue tracker.

I hope this helps! :+1: I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can always reopen this :+1: