Exemple #1
0
        public static unsafe int EndSendMessage(ref NetworkInterfaceSendHandle handle, ref NetworkInterfaceEndPoint address, IntPtr userData, ref NetworkSendQueueHandle sendQueue)
        {
            network_iovec iov;

            iov.buf = (void *)handle.data;
            iov.len = handle.size;
            int errorcode = 0;
            var addr      = address;

            return(NativeBindings.network_sendmsg(*(long *)userData, &iov, 1, ref *(network_address *)addr.data, ref errorcode));
        }
        private static unsafe int EndSendMessage(ref NetworkInterfaceSendHandle handle, ref NetworkInterfaceEndPoint address, IntPtr userData, ref NetworkSendQueueHandle sendQueueHandle)
        {
            var baselib = (BaselibData *)userData;
            int index   = handle.id;
            var message = baselib->m_PayloadsTx.GetRequestFromHandle(index);

            message.requestUserdata = (IntPtr)(index + 1);
            message.payload.size    = (uint)handle.size;

            var addr = address;

            UnsafeUtility.MemCpy((void *)message.remoteEndpoint.slice.data, addr.data, address.dataLength);

            NetworkRequest *messagePtr = &message;

            var error = default(ErrorState);
            var count = (int)Binding.Baselib_RegisteredNetwork_Socket_UDP_ScheduleSend(
                baselib->m_Socket,
                messagePtr,
                1u,
                error.NativeErrorStatePtr);

            if (error.ErrorCode != ErrorCode.Success)
            {
                baselib->m_PayloadsTx.ReleaseHandle(index);
                return(-1);
            }
            return(handle.size);
        }