Re: [go-nuts] golang tcp transport just like nc
On Wed, 7 Mar 2018 19:16:33 -0800 (PST) sucong...@gmail.com wrote: > > > linux nc command port to golang > > > in nc , we can do this > > echo 'my id is 1' > /tmp/1 > echo 'my id is 3' > /tmp/3 > rm -rf /tmp/2 /tmp/4 > > > > server > > nc -l 19090 < /tmp/1 > /tmp/2 > > ( if you are in linux not mac this may be ` nc -l -p 19090 ` ) > > client > > > nc 127.0.0.1 19090 < /tmp/3 > /tmp/4 > > > when finish ,both server and client will be closed > > client send /tmp/3 is saved by server to /tmp/2 > > server send /tmp/1 is saved by server to /tmp/4 > > then use golang do the same thing , but when finished , both server > and client can not closed automaticly > > > > echo 'my id is 1' > /tmp/1 > echo 'my id is 3' > /tmp/3 > rm -rf /tmp/2 /tmp/4 > > > > > > ./nc serer < /tmp/1 > /tmp/2 > > > > ./nc < /tmp/3 > /tmp/4 > > > > please help me how to solve this and works like nc > > > example code > > https://gist.github.com/suconghou/a1bfab9a30b3408400b6382d73051227 > > > See https://play.golang.org/p/6ljoK4EB9iY You must use CloseRead/CloseWrite Jamil Djadala -- Jamil Djadala -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] golang tcp transport just like nc
Once you've read all of os.Stdin, and the io.Copy finishes, you need to call conn.CloseWrite(), to signal to the other side that it won't receive any more bytes. Otherwise each side is blocked in io.Copy(os.Stdout, conn) waiting for more bytes to arrive from the other side. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] golang tcp transport just like nc
linux nc command port to golang in nc , we can do this echo 'my id is 1' > /tmp/1 echo 'my id is 3' > /tmp/3 rm -rf /tmp/2 /tmp/4 server nc -l 19090 < /tmp/1 > /tmp/2 ( if you are in linux not mac this may be ` nc -l -p 19090 ` ) client nc 127.0.0.1 19090 < /tmp/3 > /tmp/4 when finish ,both server and client will be closed client send /tmp/3 is saved by server to /tmp/2 server send /tmp/1 is saved by server to /tmp/4 then use golang do the same thing , but when finished , both server and client can not closed automaticly echo 'my id is 1' > /tmp/1 echo 'my id is 3' > /tmp/3 rm -rf /tmp/2 /tmp/4 ./nc serer < /tmp/1 > /tmp/2 ./nc < /tmp/3 > /tmp/4 please help me how to solve this and works like nc example code https://gist.github.com/suconghou/a1bfab9a30b3408400b6382d73051227 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.