static UdtSockHandle E(UdtSockHandle h) { if ((int)h == -1) { throw new UdtException(); } return(h); }
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)); }
internal static extern long SendFile(UdtSockHandle u, string path, ref long offset, long size, int block = 364000);
internal static extern int RecvBytes(UdtSockHandle u, byte[] buf, int len);
internal static extern int SendBytes(UdtSockHandle u, byte[] buf, int len, int ttl = -1, bool inorder = false);
internal static extern int Recv(UdtSockHandle u, byte[] buf, int len, int flags);
internal static extern int SetSockOpt(UdtSockHandle u, int level, UdtOption optname, ref byte[] optval, int optlen);
private UdtSocket(UdtSockHandle handle) { this.handle = handle; }
internal static extern int PerfMon(UdtSockHandle u, out UdtPerfInfo perf, bool clear = true);
internal static extern int Close(UdtSockHandle u);
internal static extern int Connect(UdtSockHandle u, ref SockAddr name, int namelen);
internal static extern UdtSockHandle Accept(UdtSockHandle u, out SockAddr name, out int namelen);
internal static extern int Listen(UdtSockHandle u, int backlog);
internal static extern int Bind(UdtSockHandle u, ref SockAddr name, int namelen);
internal static extern long RecvFile(UdtSockHandle u, string path, ref long offset, long size, int block = 7280000);
internal static extern int EpollRemoveUdtSock(int eid, UdtSockHandle u);
internal static extern int GetSockName(UdtSockHandle u, out SockAddr name, out int namelen);
internal static extern UdtState GetSockState(UdtSockHandle u);
internal static extern int GetSockOpt(UdtSockHandle u, int level, UdtOption optname, out byte[] optval, out int optlen);