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

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

            SockAddr addr = new SockAddr(remoteEndpoint);

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

            SockAddr addr = new SockAddr(localEndpoint);

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