AsyncSocketOpts_ID optID,
void *valuePtr,
socklen_t *outBufLen);
+static void AsyncTCPSocketListenerError(int error,
+ AsyncSocket *asock,
+ void *clientData);
/* Local constants. */
AsyncTCPSocketSetState(asock, AsyncSocketListening);
asock->listenAsock6 = asock6;
asock->listenAsock4 = asock4;
+ AsyncSocket_SetErrorFn(BaseSocket(asock4),
+ AsyncTCPSocketListenerError,
+ asock);
+ AsyncSocket_SetErrorFn(BaseSocket(asock6),
+ AsyncTCPSocketListenerError,
+ asock);
return BaseSocket(asock);
} else if (asock6) {
s->genericErrno = sysErr;
if (sysErr == ASOCK_EWOULDBLOCK) {
TCPSOCKWARN(s, ("spurious accept notification\n"));
-
+#if TARGET_OS_IPHONE
+ /*
+ * For iOS, while the app is suspended and device's screen is locked,
+ * system will reclaim resources from underneath socket(see Apple
+ * Technical Note TN2277), the callback function AsyncTCPSocketAcceptCallback()
+ * will be invoked repeatedly, to deal with this issue, we need to
+ * handle error EWOULDBLOCK.
+ */
+ return ASOCKERR_ACCEPT;
+#else
return ASOCKERR_GENERIC;
+#endif
#ifndef _WIN32
/*
* This sucks. Linux accept() can return ECONNABORTED for connections
AsyncTCPSocketClose(AsyncSocket *base) // IN
{
AsyncTCPSocket *asock = TCPSocket(base);
- Bool isListener = TRUE;
ASSERT(AsyncTCPSocketIsLocked(asock));
Bool removed;
AsyncSocketState oldState;
- isListener = FALSE;
-
/* Flush output if requested via AsyncTCPSocket_SetCloseOptions(). */
if (asock->flushEnabledMaxWaitMsec &&
AsyncTCPSocketGetState(asock) == AsyncSocketConnected &&
return BaseSocket(asock);
}
#endif
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * AsyncTCPSocketListenerError --
+ *
+ * Call the error handler from parent AsyncSocket object. The passed in
+ * parameter clientData is the parent AsyncSocket object.
+ *
+ * Result
+ * None
+ *
+ * Side-effects
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+AsyncTCPSocketListenerError(int error, // IN
+ AsyncSocket *asock, // IN
+ void *clientData) // IN
+{
+ AsyncSocket *s = clientData;
+ ASSERT(s);
+
+ AsyncSocketHandleError(s, error);
+}