示例#1
0
void CheckForConnection() {
    Socket newSocket = NetAcceptTCP(listeningSocket);

    if (newSocket != INVALID_SOCKET) {
        if (connected) {
            SendResponseMessage("New connection made.  Goodbye.\n", 3);
            NetCloseTCP(interfaceSocket);
        }
        interfaceSocket = newSocket;

        DebugPrint("Established socket interface connection to %d.%d.%d.%d port %d\n" _C_ NIPQUAD(ntohl(NetLastHost)) _C_ NetLastPort);
        NetSetNonBlocking(interfaceSocket);
        connected = true;
    }
}
示例#2
0
void SocketInterfaceInit() {
    int result;

    DebugPrint("Initializing Socket Interface.\n");
    connected = false;

    NetInit();
    listeningSocket = NetOpenTCP(SocketInterfacePort);
    NetSetNonBlocking(listeningSocket);
    result = NetListenTCP(listeningSocket);

#ifdef WIN32
    DebugPrint("Socket interface initialized.\nListening on port %d, result = %d, error = %d\n" _C_ SocketInterfacePort _C_ result _C_ WSAGetLastError());
#else
    DebugPrint("Socket interface initialized.\nListening on port %d, result = %d\n" _C_ SocketInterfacePort _C_ result);
#endif
}
示例#3
0
 void SetNonBlocking() {
     NetSetNonBlocking(socket);
 }