Establish tcp connection through normal files.(not socket file)
Let's say there are two computers, they shared a disk.
- Computer1 open file1 READ_ONLY as input, open file2 READ_WRITE as output in sharing disk;
- Computer2 open file2 READ_ONLY as input, open file1 READ_WRITE as output in sharing disk;
- Computer1 dial tcp connection, and read file1 data then write to tcp connection, read tcp connection data then write to file2;
- Computer2 listen local port, when there is connection, read connection data write to file1, also read file2 data write to tcp connection.
So, we just establish tcp connection through two common shared files.
- terminal 1:
python3 -m http.server 12345 # prepare a example tcp server
- terminal 2:
touch input;
touch output;
go run main.go -type server -input input -output output -forward "12345"
- terminal 3:
go run main.go -type client -input output -output input -listen "54321"
- terminal 4:
curl http://localhost:54321 # you just view to step 1 python http server