Esempio n. 1
0
        static string GetErrorDesc()
        {
            IntPtr p   = UDT.GetLastErrorDesc();
            string str = Marshal.PtrToStringAnsi(p);

            return(str);
        }
Esempio n. 2
0
        public void Connect(IPEndPoint remoteEndpoint)
        {
            CheckAddrVer(remoteEndpoint.AddressFamily);

            SockAddr addr = new SockAddr(remoteEndpoint);

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

            SockAddr addr = new SockAddr(localEndpoint);

            E(UDT.Bind(this.handle, ref addr, addr.Size));
        }
Esempio n. 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();
            }
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 7
0
 public UdtException() : base(GetErrorDesc())
 {
     this.ErrorCode = UDT.GetLastErrorCode();
 }
Esempio n. 8
0
 public int Send(byte[] buf, int length)
 {
     return(UDT.Send(this.handle, buf, length, 0));
 }
Esempio n. 9
0
 public void Listen(int backlog)
 {
     E(UDT.Listen(this.handle, backlog));
 }
Esempio n. 10
0
 static UdtSocket()
 {
     E(UDT.Startup());
 }
Esempio n. 11
0
 public void Dispose()
 {
     UDT.Close(this.handle);
 }
Esempio n. 12
0
 public int ReceiveBytes(byte[] buf)
 {
     return(UDT.RecvBytes(this.handle, buf, buf.Length));
 }
Esempio n. 13
0
 public int Receive(byte[] buf)
 {
     return(UDT.Recv(this.handle, buf, buf.Length, 0));
 }