--- Source/OPNetModules/Posix/TCP_IP/tcp_module_communication.cpp.orig	Tue Oct 29 23:57:33 2002
+++ Source/OPNetModules/Posix/TCP_IP/tcp_module_communication.cpp	Tue Oct 29 23:58:59 2002
@@ -50,6 +50,9 @@
 	#include <pthread.h>
 #endif
 
+// this hacks in minimal support for EAGAIN for asynchronous communications
+#define HACKY_EAGAIN
+
 // -------------------------------  Private Definitions
 
 //since we are multithreaded, we have to use a mutual-exclusion locks for certain items
@@ -638,8 +641,20 @@
 
 		if (result == -1)
 		{
+#ifdef HACKY_EAGAIN
+			if ( errno == EAGAIN )
+			{
+				result = 0;
+			}
+			else
+			{
+				DEBUG_NETWORK_API("send",result);
+				return(kNMInternalErr);
+			}
+#else
 			DEBUG_NETWORK_API("send",result);
 			return(kNMInternalErr);
+#endif // HACKY_EAGAIN
 		}
 
 		offset += result;
@@ -690,7 +705,6 @@
 
 	if (inEndpoint->needToDie == true)
 		return kNMNoDataErr;
-	
 	result = recv(inEndpoint->sockets[which_socket], (char *)ioData, *ioSize, 0);
 
 	if (result == 0)
@@ -1180,8 +1194,13 @@
 	  		if (!err)
 			{
 		 		required_port = 0;
-
-				     // if we need a datagram socket
+				// This socket needs to be non-blocking or
+				// things will lock up later...
+#ifdef HACKY_EAGAIN
+				SetNonBlockingMode(new_endpoint->sockets[_stream_socket]);
+#endif // HACKY_EAGAIN
+				
+					// if we need a datagram socket
 		      	if (inEndpoint->connectionMode & 1)
 		 		{
 					// create the datagram socket with the default port and host set..
@@ -2413,7 +2432,11 @@
 	{
 		//windows complains if the buffer isnt big enough to fit the datagram. i dont think any unixes do.
 		//this of course is not a problem
+#ifdef HACKY_EAGAIN
+		if ( (op_errno == EMSGSIZE) || (op_errno == EAGAIN) )
+#else
 		if (op_errno == EMSGSIZE)
+#endif // HACKY_EAGAIN
 			return 4; //pretend we read it and go home happy
 		DEBUG_NETWORK_API("socketReadResult",result);
 		return recvfrom(socket,(char*)buffer,sizeof(buffer),0,NULL,NULL);
