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

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

            SockAddr addr = new SockAddr(remoteEndpoint);

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

            SockAddr addr = new SockAddr(localEndpoint);

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