From 2b8da85d9f6270edd5a83b35d5116de216ace06e Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 10 Nov 2017 18:02:05 -0800 Subject: Handle the client closing the connection better. On the server side, don't treat an immediate EOF when trying to read a message header as an error, just silently terminate the session. Treat EOFs after reading *some* of the message as an error. --- sockutils.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sockutils.h') diff --git a/sockutils.h b/sockutils.h index 87f9c65d..20127f03 100644 --- a/sockutils.h +++ b/sockutils.h @@ -168,10 +168,14 @@ int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD, /* 'server' flag; it opens a server socket */ #define SOCKOPEN_SERVER 1 -/* Changes the behaviour of the sock_recv(); it does not wait to receive all data */ -#define SOCK_RECEIVEALL_NO 0 -/* Changes the behaviour of the sock_recv(); it waits to receive all data */ -#define SOCK_RECEIVEALL_YES 1 +/* + * Flags for sock_recv(). + */ +#define SOCK_RECEIVEALL_NO 0x00000000 /* Don't wait to receive all data */ +#define SOCK_RECEIVEALL_YES 0x00000001 /* Wait to receive all data */ + +#define SOCK_EOF_ISNT_ERROR 0x00000000 /* Return 0 on EOF */ +#define SOCK_EOF_IS_ERROR 0x00000002 /* Return an error on EOF */ /* * \} -- cgit v1.2.1