static string GetErrorDesc() { IntPtr p = UDT.GetLastErrorDesc(); string str = Marshal.PtrToStringAnsi(p); return(str); }
public void Connect(IPEndPoint remoteEndpoint) { CheckAddrVer(remoteEndpoint.AddressFamily); SockAddr addr = new SockAddr(remoteEndpoint); E(UDT.Connect(this.handle, ref addr, addr.Size)); }
public void Bind(IPEndPoint localEndpoint) { CheckAddrVer(localEndpoint.AddressFamily); SockAddr addr = new SockAddr(localEndpoint); E(UDT.Bind(this.handle, ref addr, addr.Size)); }
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(); } }
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)); }
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)); }
public UdtException() : base(GetErrorDesc()) { this.ErrorCode = UDT.GetLastErrorCode(); }
public int Send(byte[] buf, int length) { return(UDT.Send(this.handle, buf, length, 0)); }
public void Listen(int backlog) { E(UDT.Listen(this.handle, backlog)); }
static UdtSocket() { E(UDT.Startup()); }
public void Dispose() { UDT.Close(this.handle); }
public int ReceiveBytes(byte[] buf) { return(UDT.RecvBytes(this.handle, buf, buf.Length)); }
public int Receive(byte[] buf) { return(UDT.Recv(this.handle, buf, buf.Length, 0)); }