Merge branch '1.1-rel'
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / tcp_adapter / catcpserver.c
index 3d9ef2f..257c6e0 100644 (file)
@@ -248,6 +248,21 @@ static void CASelectReturned(fd_set *readFds, int ret)
         FD_CLR(caglobals.tcp.connectionFds[0], readFds);
         return;
     }
+    else if (-1 != caglobals.tcp.connectionFds[0] &&
+            FD_ISSET(caglobals.tcp.connectionFds[0], readFds))
+    {
+        // new connection was created from remote device.
+        // exit the function to update read file descriptor.
+        char buf[MAX_ADDR_STR_SIZE_CA] = {0};
+        ssize_t len = read(caglobals.tcp.connectionFds[0], buf, sizeof (buf));
+        if (-1 == len)
+        {
+            return;
+        }
+        OIC_LOG_V(DEBUG, TAG, "Received new connection event with [%s]", buf);
+        FD_CLR(caglobals.tcp.connectionFds[0], readFds);
+        return;
+    }
     else
     {
         uint32_t length = u_arraylist_length(caglobals.tcp.svrlist);