+SocketThread::SocketThread()
+{
+ int listenFD = socket(AF_INET, SOCK_STREAM, 0);
+ if (listenFD == -1)
+ throw CoreException("Could not create ITC pipe");
+ int connFD = socket(AF_INET, SOCK_STREAM, 0);
+ if (connFD == -1)
+ throw CoreException("Could not create ITC pipe");
+
+ if (!ServerInstance->BindSocket(listenFD, 0, "127.0.0.1", true))
+ throw CoreException("Could not create ITC pipe");
+ ServerInstance->SE->NonBlocking(connFD);
+
+ struct sockaddr_in addr;
+ socklen_t sz = sizeof(addr);
+ getsockname(listenFD, reinterpret_cast<struct sockaddr*>(&addr), &sz);
+ connect(connFD, reinterpret_cast<struct sockaddr*>(&addr), sz);
+ ServerInstance->SE->Blocking(listenFD);
+ int nfd = accept(listenFD, reinterpret_cast<struct sockaddr*>(&addr), &sz);
+ if (nfd < 0)
+ throw CoreException("Could not create ITC pipe");
+ new ThreadSignalSocket(this, nfd);
+ closesocket(listenFD);
+
+ ServerInstance->SE->Blocking(connFD);
+ this->signal.connFD = connFD;