Browse Source

docs(net): add comment about `EPIPE` -> `Connection_Closed`

Rickard Andersson 1 year ago
parent
commit
efc84cd390
1 changed files with 3 additions and 1 deletions
  1. 3 1
      core/net/socket_linux.odin

+ 3 - 1
core/net/socket_linux.odin

@@ -260,7 +260,9 @@ _send_tcp :: proc(tcp_sock: TCP_Socket, buf: []byte) -> (int, Network_Error) {
 		remaining := buf[total_written:][:limit]
 		remaining := buf[total_written:][:limit]
 		res, errno := linux.send(linux.Fd(tcp_sock), remaining, {.NOSIGNAL})
 		res, errno := linux.send(linux.Fd(tcp_sock), remaining, {.NOSIGNAL})
 		if errno == .EPIPE {
 		if errno == .EPIPE {
-			return total_written, TCP_Send_Error.Connection_Closed
+			// If the peer is disconnected when we are trying to send we will get an `EPIPE` error,
+			// so we turn that into a clearer error
+			return total_written, .Connection_Closed
 		} else if errno != .NONE {
 		} else if errno != .NONE {
 			return total_written, TCP_Send_Error(errno)
 			return total_written, TCP_Send_Error(errno)
 		}
 		}