Pithikos / python-websocket-server

A simple fully working websocket-server in Python with no external dependencies
MIT License
1.15k stars 385 forks source link

send vs sendall #62

Closed programmer101010 closed 3 years ago

programmer101010 commented 6 years ago

Would sendall be more appropriate than send in cases where send is used for a socket? See https://stackoverflow.com/questions/34252273/what-is-the-difference-between-socket-send-and-socket-sendall#34252690.

Sendall would result in a more consistent state in some cases.

Pithikos commented 3 years ago

Nope. Websocket protocol requires TCP.

programmer101010 commented 3 years ago

The answer in that stackoverflow question is better suited for this. Another link is: https://docs.python.org/2/library/socket.html#socket.socket.sendall.

For example in websocket_server/websocket_server.py (multiple occurrences and may be elsewhere as well): "self.request.send(" might be more guaranteed with "sendall" to ensure all data is passed for no checks are performed on send in this context to see if all data is passed. However, this code would need the ability to catch an error in this case.

This is still relevant for Python 3 (not sure which version this supports).

Thanks for your work :)

Pithikos commented 3 years ago

Is there an example or incident that happened that would require this change? Namely I'm fine with changing things but would need some good reasoning.. e.g. an example where send() is not good enough? An example would be ideal