예제 #1
0
        static string GetErrorDesc()
        {
            IntPtr p   = UDT.GetLastErrorDesc();
            string str = Marshal.PtrToStringAnsi(p);

            return(str);
        }
예제 #2
0
        public void Connect(IPEndPoint remoteEndpoint)
        {
            CheckAddrVer(remoteEndpoint.AddressFamily);

            SockAddr addr = new SockAddr(remoteEndpoint);

            E(UDT.Connect(this.handle, ref addr, addr.Size));
        }
예제 #3
0
        public void Bind(IPEndPoint localEndpoint)
        {
            CheckAddrVer(localEndpoint.AddressFamily);

            SockAddr addr = new SockAddr(localEndpoint);

            E(UDT.Bind(this.handle, ref addr, addr.Size));
        }
예제 #4
0
        public void SendBytes(byte[] buf, int length)
        {
            int len = UDT.SendBytes(this.handle, buf, length, this.ttl, this.inOrder);

            if (len != length)
            {
                throw new UdtException();
            }
        }
예제 #5
0
        public UdtSocket Accept(out IPEndPoint remoteEndpoint)
        {
            SockAddr addr;
            int      addrLen;

            UdtSockHandle h = E(UDT.Accept(this.handle, out addr, out addrLen));

            Debug.Assert(addrLen == addr.Size);

            remoteEndpoint = addr.ToIPEndPoint();
            CheckAddrVer(remoteEndpoint.AddressFamily);

            return(new UdtSocket(h));
        }
예제 #6
0
        public UdtSocket(ProtocolType protocol, SocketType socketType)
        {
            if (protocol == ProtocolType.IPv4)
            {
                this.af = AddressFamily.InterNetwork;
            }
            else if (protocol == ProtocolType.IPv6)
            {
                this.af = AddressFamily.InterNetworkV6;
            }
            else
            {
                throw new ArgumentException("protocol", new NotSupportedException("Only support IPv4 and IPv6"));
            }

            this.handle = E(UDT.CreateSocket(this.af, socketType, protocol));
        }
예제 #7
0
 public UdtException() : base(GetErrorDesc())
 {
     this.ErrorCode = UDT.GetLastErrorCode();
 }
예제 #8
0
 public int Send(byte[] buf, int length)
 {
     return(UDT.Send(this.handle, buf, length, 0));
 }
예제 #9
0
 public void Listen(int backlog)
 {
     E(UDT.Listen(this.handle, backlog));
 }
예제 #10
0
 static UdtSocket()
 {
     E(UDT.Startup());
 }
예제 #11
0
 public void Dispose()
 {
     UDT.Close(this.handle);
 }
예제 #12
0
 public int ReceiveBytes(byte[] buf)
 {
     return(UDT.RecvBytes(this.handle, buf, buf.Length));
 }
예제 #13
0
 public int Receive(byte[] buf)
 {
     return(UDT.Recv(this.handle, buf, buf.Length, 0));
 }