Skip to content

Comments

The _close method has been separately overridden for UdpTransport and TcpTransport#107

Closed
klin111 wants to merge 1 commit intoeht16:masterfrom
klin111:master
Closed

The _close method has been separately overridden for UdpTransport and TcpTransport#107
klin111 wants to merge 1 commit intoeht16:masterfrom
klin111:master

Conversation

@klin111
Copy link

@klin111 klin111 commented Feb 22, 2025

"The close method is overridden separately for UDP protocol because the shutdown of a UDP connection does not require cleaning up with wait_for_socket_buffer_empty, or using _sock.shutdown(socket.SHUT_WR) method. This avoids encountering connection errors when working with UDP, such as: 'Error on closing the transport socket: [Errno 107] Transport endpoint is not connected.'"
This explanation highlights the necessity of customizing the closing behavior for different protocols to ensure optimal performance and error handling. In the case of UDP, which is a connectionless protocol, certain steps taken for connection-oriented protocols like TCP (such as waiting for the socket buffer to empty or shutting down the write direction of the socket) are not applicable and can be omitted to prevent potential errors.

…own(socket.SHUT_WR).避免使用udp时候,出现连接报错,如:"Error on closing the transport socket: [Errno 107] Transport endpoint is not connected"
@eht16
Copy link
Owner

eht16 commented Feb 22, 2025

Could you elobarate on the relation of socket buffer and connection less protocols?
As far as I see, the kernel uses receive and send buffers for UDP as well.
I might be wrong and if you could provide some resource to verify, it'd be great.

@eht16 eht16 closed this in 6de57d1 Mar 16, 2025
@eht16
Copy link
Owner

eht16 commented Mar 16, 2025

Implemented a little differently in 6de57d1. Details in #108.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants