summaryrefslogtreecommitdiff
path: root/nuttx/net/net_internal.h
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-18 18:13:30 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-18 18:13:30 +0000
commitfadbb925a6a118790d8d661fea3956bb0f76348a (patch)
treeca4c58d32d12949e8d08cb69a652b5e3f7fd0e58 /nuttx/net/net_internal.h
parent376af5201c555ee163045a8103d8e592f9a1b1bc (diff)
downloadpx4-nuttx-fadbb925a6a118790d8d661fea3956bb0f76348a.tar.gz
px4-nuttx-fadbb925a6a118790d8d661fea3956bb0f76348a.tar.bz2
px4-nuttx-fadbb925a6a118790d8d661fea3956bb0f76348a.zip
Correct and error in recv() and recvfrom() return value
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4402 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/net_internal.h')
-rw-r--r--nuttx/net/net_internal.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/nuttx/net/net_internal.h b/nuttx/net/net_internal.h
index 190d57815..e130b42e8 100644
--- a/nuttx/net/net_internal.h
+++ b/nuttx/net/net_internal.h
@@ -57,16 +57,25 @@
/* Definitions of 8-bit socket flags */
/* Bits 0-2: Socket state */
-#define _SF_IDLE 0x00 /* There is no socket activity */
-#define _SF_ACCEPT 0x01 /* Socket is waiting to accept a connection */
-#define _SF_RECV 0x02 /* Waiting for recv action to complete */
-#define _SF_SEND 0x03 /* Waiting for send action to complete */
-#define _SF_MASK 0x03 /* Mask to isolate the above actions */
- /* Bit 3: unused */
-#define _SF_NONBLOCK 0x10 /* Bit 4: Don't block if no data (TCP/READ only) */
-#define _SF_LISTENING 0x20 /* Bit 5: SOCK_STREAM is listening */
-#define _SF_BOUND 0x40 /* Bit 6: SOCK_STREAM is bound to an address */
-#define _SF_CONNECTED 0x80 /* Bit 7: SOCK_STREAM is connected */
+#define _SF_IDLE 0x00 /* - There is no socket activity */
+#define _SF_ACCEPT 0x01 /* - Socket is waiting to accept a connection */
+#define _SF_RECV 0x02 /* - Waiting for recv action to complete */
+#define _SF_SEND 0x03 /* - Waiting for send action to complete */
+#define _SF_MASK 0x03 /* - Mask to isolate the above actions */
+
+#define _SF_NONBLOCK 0x08 /* Bit 3: Don't block if no data (TCP/READ only) */
+#define _SF_LISTENING 0x10 /* Bit 4: SOCK_STREAM is listening */
+#define _SF_BOUND 0x20 /* Bit 5: SOCK_STREAM is bound to an address */
+ /* Bits 6-7: Connection state */
+#define _SF_CONNECTED 0x40 /* Bit 6: SOCK_STREAM is connected */
+#define _SF_CLOSED 0x80 /* Bit 7: SOCK_STREAM was gracefully disconnected */
+
+/* Connection state encoding:
+ *
+ * _SF_CONNECTED==1 && _SF_CLOSED==0 - the socket is connected
+ * _SF_CONNECTED==0 && _SF_CLOSED==1 - the socket was gracefully disconnected
+ * _SF_CONNECTED==0 && _SF_CLOSED==0 - the socket was rudely disconnected
+ */
/* Macro to manage the socket state and flags */
@@ -78,6 +87,7 @@
#define _SS_ISLISTENING(s) (((s) & _SF_LISTENING) != 0)
#define _SS_ISBOUND(s) (((s) & _SF_CONNECTED) != 0)
#define _SS_ISCONNECTED(s) (((s) & _SF_CONNECTED) != 0)
+#define _SS_ISCLOSED(s) (((s) & _SF_CLOSED) != 0)
/* This macro converts a socket option value into a bit setting */