예제 #1
0
        public SocketCpp Accept()
        {
            AcceptPara para = new AcceptPara();

            SocketCpp.getAccept(this.socket, ref para);

            SimpleSocketException ex;

            if (para.errorCode != 0)
            {
                ex = new SimpleSocketException(
                    "Accept 发生错误, errorCode:" + para.errorCode,
                    para.errorCode);

                throw ex;
            }

            return(new SocketCpp(para.socket));
        }
예제 #2
0
        public int Send(byte[] buffer)
        {
            SendPara para = new SendPara();

            para.socket       = this.socket;
            para.bufferLength = buffer.Length;

            SocketCpp.getSend(ref para, buffer);

            SimpleSocketException ex;

            if (para.errorCode != 0)
            {
                ex = new SimpleSocketException(
                    "Send 发生错误, errorCode:" + para.errorCode,
                    para.errorCode);

                throw ex;
            }

            return(para.resultLength);
        }
예제 #3
0
        public static SocketCpp CreateAndListen(string host, string port)
        {
            CreatePara para = new CreatePara();

            para.host = host;
            para.port = port;

            SocketCpp.getSocket(ref para);

            SimpleSocketException ex;

            if (para.errorCode != 0)
            {
                ex = new SimpleSocketException(
                    "CreateAndListen 发生错误, errorCode:" + para.errorCode,
                    para.errorCode);

                throw ex;
            }

            return(new SocketCpp(para.socket));
        }