コード例 #1
0
ファイル: TcpServer.cs プロジェクト: nietras/benchmarks
        public TcpServer(ushort port, byte address1, byte address2, byte address3, byte address4)
        {
            var version = new TcpServer.Version(2, 2);
            WSDATA data;
            int result = SocketImports.WSAStartup((short)version.Raw, out data);
            if (result != 0)
            {
                var error = SocketImports.WSAGetLastError();
                throw new Exception(String.Format("ERROR: WSAStartup returned {0}", error));
            }

            _handle = SocketImports.socket(ADDRESS_FAMILIES.AF_INET, SOCKET_TYPE.SOCK_STREAM, PROTOCOL.IPPROTO_TCP);
            if (_handle == IntPtr.Zero)
            {
                var error = SocketImports.WSAGetLastError();
                SocketImports.WSACleanup();
                throw new Exception(String.Format("ERROR: socket returned {0}", error));
            }

            Start(port, address1, address2, address3, address4);
        }
コード例 #2
0
ファイル: TcpServer.cs プロジェクト: zcorp/benchmarks
        public TcpServer(ushort port, byte address1, byte address2, byte address3, byte address4)
        {
            var    version = new TcpServer.Version(2, 2);
            WSDATA data;
            int    result = SocketImports.WSAStartup((short)version.Raw, out data);

            if (result != 0)
            {
                var error = SocketImports.WSAGetLastError();
                throw new Exception(String.Format("ERROR: WSAStartup returned {0}", error));
            }

            _handle = SocketImports.socket(ADDRESS_FAMILIES.AF_INET, SOCKET_TYPE.SOCK_STREAM, PROTOCOL.IPPROTO_TCP);
            if (_handle == IntPtr.Zero)
            {
                var error = SocketImports.WSAGetLastError();
                SocketImports.WSACleanup();
                throw new Exception(String.Format("ERROR: socket returned {0}", error));
            }

            Start(port, address1, address2, address3, address4);
        }