Skip to content

send should check socket status and fail if the socket is closed #169

@Yuras

Description

@Yuras

The Network.Socket.close claims that

All future operations on the socket object will fail

It changes socket state to Closed and calls close(2) C function, so OS is free to reuse the FD.

But Network.Socket.send and friends don't check socket status. When sending data to a closed socket usually an exception is thrown (close(2) returns EBADF), but there is a chance that the FD is reused after close but before send, so the data will be silently sent to a wrong destination.

One can argue that writing to a closed socket is a bad practice anyway, then please consider it as a documentation bug.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions