Index: trunk/src/emx/include/sys/socket.h
===================================================================
--- trunk/src/emx/include/sys/socket.h	(revision 380)
+++ trunk/src/emx/include/sys/socket.h	(revision 382)
@@ -471,4 +471,5 @@
 int     TCPCALL sock_init( void );
 int     TCPCALL sock_errno( void );
+int     TCPCALL os2_sock_errno( void );
 void    TCPCALL psock_errno( char * );
 int     TCPCALL soclose( int );
Index: trunk/src/emx/src/lib/socket/sock_errno.c
===================================================================
--- trunk/src/emx/src/lib/socket/sock_errno.c	(revision 382)
+++ trunk/src/emx/src/lib/socket/sock_errno.c	(revision 382)
@@ -0,0 +1,20 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+
+
+/**
+ * Get the last socket error number.
+ * This wrapper is required to get match our error defines in errno.h. OS/2
+ * tcpip uses the FreeBSD / M$C errno.h values with an offset of 10000.
+ *
+ * @returns libc compatible errno for last socket operation.
+ */
+int _System sock_errno(void)
+{
+    /* get the OS/2 error. */
+    int err = os2_sock_errno();
+    if (err > 10000 && err < 11000)
+        err -= 10000;
+    return err;
+}
+
Index: trunk/src/emx/src/lib/socket/socket.imp
===================================================================
--- trunk/src/emx/src/lib/socket/socket.imp	(revision 380)
+++ trunk/src/emx/src/lib/socket/socket.imp	(revision 382)
@@ -43,6 +43,6 @@
 soabort                 tcpip32   19 ?
 _soabort                tcpip32   19 ?
-sock_errno              tcpip32   20 ?
-_sock_errno             tcpip32   20 ?
+os2_sock_errno          tcpip32   20 ?
+_os2_sock_errno        tcpip32   20 ?
 recvmsg                 tcpip32   21 ?
 _recvmsg                tcpip32   21 ?
Index: trunk/src/emx/src/lib/socket/socket.smak
===================================================================
--- trunk/src/emx/src/lib/socket/socket.smak	(revision 380)
+++ trunk/src/emx/src/lib/socket/socket.smak	(revision 382)
@@ -10,4 +10,5 @@
 .TKIND	:= aout prof
 .TSRC   := $(wildcard src/lib/socket/386/*.s)
+.TSRC   += src/lib/socket/sock_errno.c
 .IMPS   := src/lib/socket/socket.imp
 .INSDIR	:= lib/
@@ -18,4 +19,5 @@
 .TKIND	:= aout
 .TSRC   := $(wildcard src/lib/socket/386/*.s)
+.TSRC   += src/lib/socket/sock_errno.c
 .IMPS   := src/lib/socket/socket.imp
 .INSDIR	:= lib/
@@ -27,5 +29,5 @@
 .TKIND	:= aout prof
 .TSRC   := $(wildcard src/lib/socket/386/*.s)
-.TSRC	+= src/lib/socket/herror.c
+.TSRC	+= src/lib/socket/herror.c src/lib/socket/sock_errno.c
 .IMPS   := src/lib/socket/socket_tcpipv4.imp
 .INSDIR	:= lib/
@@ -36,5 +38,5 @@
 .TKIND	:= aout
 .TSRC   := $(wildcard src/lib/socket/386/*.s)
-.TSRC	+= src/lib/socket/herror.c
+.TSRC	+= src/lib/socket/herror.c src/lib/socket/sock_errno.c
 .IMPS   := src/lib/socket/socket_tcpipv4.imp
 .TKEEP	:= 1
Index: trunk/src/emx/src/lib/socket/socket_tcpipv4.imp
===================================================================
--- trunk/src/emx/src/lib/socket/socket_tcpipv4.imp	(revision 380)
+++ trunk/src/emx/src/lib/socket/socket_tcpipv4.imp	(revision 382)
@@ -43,6 +43,6 @@
 soabort                 so32dll   19 ?
 _soabort                so32dll   19 ?
-sock_errno              so32dll   20 ?
-_sock_errno             so32dll   20 ?
+os2_sock_errno          so32dll   20 ?
+_os2_sock_errno         so32dll   20 ?
 recvmsg                 so32dll   21 ?
 _recvmsg                so32dll   21 ?
Index: trunk/src/emx/src/libsocket/sock_errno.c
===================================================================
--- trunk/src/emx/src/libsocket/sock_errno.c	(revision 382)
+++ trunk/src/emx/src/libsocket/sock_errno.c	(revision 382)
@@ -0,0 +1,20 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+
+
+/**
+ * Get the last socket error number.
+ * This wrapper is required to get match our error defines in errno.h. OS/2
+ * tcpip uses the FreeBSD / M$C errno.h values with an offset of 10000.
+ *
+ * @returns libc compatible errno for last socket operation.
+ */
+int _System sock_errno(void)
+{
+    /* get the OS/2 error. */
+    int err = os2_sock_errno();
+    if (err > 10000 && err < 11000)
+        err -= 10000;
+    return err;
+}
+
Index: trunk/src/emx/src/libsocket/socket.imp
===================================================================
--- trunk/src/emx/src/libsocket/socket.imp	(revision 380)
+++ trunk/src/emx/src/libsocket/socket.imp	(revision 382)
@@ -43,6 +43,6 @@
 soabort                 tcpip32   19 ?
 _soabort                tcpip32   19 ?
-sock_errno              tcpip32   20 ?
-_sock_errno             tcpip32   20 ?
+os2_sock_errno          tcpip32   20 ?
+_os2_sock_errno        tcpip32   20 ?
 recvmsg                 tcpip32   21 ?
 _recvmsg                tcpip32   21 ?
Index: trunk/src/emx/src/libsocket/socket.smak
===================================================================
--- trunk/src/emx/src/libsocket/socket.smak	(revision 380)
+++ trunk/src/emx/src/libsocket/socket.smak	(revision 382)
@@ -10,4 +10,5 @@
 .TKIND	:= aout prof
 .TSRC   := $(wildcard src/lib/socket/386/*.s)
+.TSRC   += src/lib/socket/sock_errno.c
 .IMPS   := src/lib/socket/socket.imp
 .INSDIR	:= lib/
@@ -18,4 +19,5 @@
 .TKIND	:= aout
 .TSRC   := $(wildcard src/lib/socket/386/*.s)
+.TSRC   += src/lib/socket/sock_errno.c
 .IMPS   := src/lib/socket/socket.imp
 .INSDIR	:= lib/
@@ -27,5 +29,5 @@
 .TKIND	:= aout prof
 .TSRC   := $(wildcard src/lib/socket/386/*.s)
-.TSRC	+= src/lib/socket/herror.c
+.TSRC	+= src/lib/socket/herror.c src/lib/socket/sock_errno.c
 .IMPS   := src/lib/socket/socket_tcpipv4.imp
 .INSDIR	:= lib/
@@ -36,5 +38,5 @@
 .TKIND	:= aout
 .TSRC   := $(wildcard src/lib/socket/386/*.s)
-.TSRC	+= src/lib/socket/herror.c
+.TSRC	+= src/lib/socket/herror.c src/lib/socket/sock_errno.c
 .IMPS   := src/lib/socket/socket_tcpipv4.imp
 .TKEEP	:= 1
Index: trunk/src/emx/src/libsocket/socket_tcpipv4.imp
===================================================================
--- trunk/src/emx/src/libsocket/socket_tcpipv4.imp	(revision 380)
+++ trunk/src/emx/src/libsocket/socket_tcpipv4.imp	(revision 382)
@@ -43,6 +43,6 @@
 soabort                 so32dll   19 ?
 _soabort                so32dll   19 ?
-sock_errno              so32dll   20 ?
-_sock_errno             so32dll   20 ?
+os2_sock_errno          so32dll   20 ?
+_os2_sock_errno         so32dll   20 ?
 recvmsg                 so32dll   21 ?
 _recvmsg                so32dll   21 ?
