From b0df514344e9e2c29f1e02e76e6d1c6924cfbc0c Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 13 Nov 2017 04:12:22 -0500 Subject: [PATCH] Clarify that WebSocket.{recv,recvmsg} may return empty messages Signed-off-by: Anders Kaseorg --- websockify/websocket.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websockify/websocket.py b/websockify/websocket.py index ae39f46..182056e 100644 --- a/websockify/websocket.py +++ b/websockify/websocket.py @@ -342,10 +342,11 @@ class WebSocket(object): def recv(self): """Read data from the WebSocket. - This will return any available data on the socket. If the - socket is closed then None will be returned. The reason for - the close is found in the 'close_code' and 'close_reason' - properties. + This will return any available data on the socket (which may + be the empty string if the peer sent an empty message or + messages). If the socket is closed then None will be + returned. The reason for the close is found in the + 'close_code' and 'close_reason' properties. Unlike recvmsg() this method may return data from more than one WebSocket message. It is however not guaranteed to return all @@ -360,10 +361,11 @@ class WebSocket(object): def recvmsg(self): """Read a single message from the WebSocket. - This will return a single WebSocket message from the socket. - If the socket is closed then None will be returned. The - reason for the close is found in the 'close_code' and - 'close_reason' properties. + This will return a single WebSocket message from the socket + (which will be the empty string if the peer sent an empty + message). If the socket is closed then None will be + returned. The reason for the close is found in the + 'close_code' and 'close_reason' properties. Unlike recv() this method will not return data from more than one WebSocket message. Callers should continue calling