public byte[] Recv(int size, out IPEndPoint remote) { var buffer = new byte[size]; var sockAddr = new SockAddr(); var addrSize = 16; var count = IO.Check(IO.RecvFrom(SocketFileDescriptor, buffer, size, 0, ref sockAddr, ref addrSize)); var slice = buffer.Take(count).ToArray(); remote = sockAddr.ToIPEndPoint(); return(slice); }
internal static extern int SendTo(FileDescriptor sockfd, byte[] buf, int len, int flags, ref SockAddr dest_addr, int addrlen);
internal static extern int RecvFrom(FileDescriptor sockfd, byte[] buf, int len, int flags, ref SockAddr dest_addr, ref int addrlen);
internal static extern int Bind(FileDescriptor sockfd, ref SockAddr addr, int addrlen);