1

I have a server that receives messages in a text-based protocol. The server doesn't send back anything. These messages eat up network bandwidth a lot since the protocol is not binary and doesn't have any compression. To fix this I want to run a compressing proxy on the client and on the server side. On the client side, the proxy should receive the data over TCP, compress it, and send to the server-side proxy. The server-side proxy should receive data, decompress it, and send to the server application.

The client-side code should be something like this:

cd /tmp
mknod backpipe p
nc localhost 7171 0<backpipe | gzip | nc server-ip 7272 | tee backpipe

And on the server side:

cd /tmp
mknod backpipe p
nc -l -p 7272 0<backpipe | gunzip | nc -l -p 7171 | tee backpipe

The server application works on 7171 port and the compressing proxy uses the 7272 port to transfer data. But this is not working for me for some reason.

1
  • netcat is not really a programming language or a programming tool. You would probably get better answers on other StackExchange sites like SuperUser or ServerFault, for instance. Commented Dec 6, 2017 at 10:12

1 Answer 1

2

You have almost got there.

client side, listen on local port 7171, forward to remote server at server-ip:7272:

mkfifo client_rely
nc -l 7171 < client_rely | gzip -c | nc server-ip 7272 > client_rely

server side, listen on port 7272, forward to real server on port 7171:

mkfifo server_rely
nc -l 7272 < server_rely | gzip -d -c | nc 7171 > server_rely

note that this example uses nc shipped with macOS.

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

Comments

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.