// addr: // struct sockaddr ontaining the address of the sender. // Can be NULL. Valid for the duration of the callback only. // // flags: // One or more or’ed UV_UDP_* constants. // Right now only UV_UDP_PARTIAL is used static void OnReceiveCallback(IntPtr handle, IntPtr nread, ref uv_buf_t buf, ref sockaddr addr, int flags) { var udp = HandleContext.GetTarget <Udp>(handle); IArrayBuffer <byte> byteBuffer = udp.GetBuffer(); int count = (int)nread.ToInt64(); IPEndPoint remoteEndPoint = count > 0 ? addr.GetIPEndPoint() : null; // // Indicates message was truncated because read buffer was too small. // The remainder was discarded by the OS. Used in uv_udp_recv_cb. // if (flags == (int)uv_udp_flags.UV_UDP_PARTIAL) { Log.Warn($"{uv_handle_type.UV_UDP} {handle} receive result truncated, buffer size = {byteBuffer.Capacity}"); } udp.OnReceivedCallback(byteBuffer, count, remoteEndPoint); }
// addr: // struct sockaddr ontaining the address of the sender. // Can be NULL. Valid for the duration of the callback only. // // flags: // One or more or’ed UV_UDP_* constants. // Right now only UV_UDP_PARTIAL is used private static void OnReceiveCallback(IntPtr handle, IntPtr nread, ref uv_buf_t buf, ref sockaddr addr, int flags) { var udp = HandleContext.GetTarget <Udp>(handle); IByteBuffer byteBuffer = udp.GetBuffer(); int count = (int)nread.ToInt64(); IPEndPoint remoteEndPoint = count > 0 ? addr.GetIPEndPoint() : null; // // Indicates message was truncated because read buffer was too small. // The remainder was discarded by the OS. Used in uv_udp_recv_cb. // if (flags == (int)uv_udp_flags.UV_UDP_PARTIAL) { Log.Handle_receive_result_truncated(handle, byteBuffer); } udp.OnReceivedCallback(byteBuffer, count, remoteEndPoint); }