Background
- To learn network programming, I tried to write raw socket by Golang, did not use
net
module.
Procedure
- Server binds socket(
syscall.Bind
) and listens(syscall.Listen
).
- Server binds socket(
- client tries to connect(
syscall.Connect
) and server accepts(syscall.Accepts
)
- client tries to connect(
- server responses "Hello" to socket by
syscall.Write
.
- server responses "Hello" to socket by
- client reads socket by
syscall.Read
- client reads socket by
then, code is here ->
https://gist.github.com/ryfjwr/21e01fb5e133861b41e981e14ced8672
Problem
above Procedure, while executing step 3, server exists because of
broken pipe
.at first, run server
$ go run tcp-server.go
then, run client
$ go run tcp-client.go
then gets
broken pipe
error.$ go run tcp-server.go
Write Error broken pipe exit
Question
- Why
Broken pipe
occurs? Any other reserch thing?- I investigated same situation,
When you have written to a connection that has already been closed by the peer.
, but, I triggerdsleep
, before client exits. - source: c++ - Socket: send() function returned 'Broken Pipe' error - Stack Overflow
- I investigated same situation,