SendMsg

Sends a message.

Synopsis

Err SendMsg( Item mp, Item msg, const void *dataptr, int32 datasize )

Description

This procedure sends a message to the specified message port. (To send a small message use SendSmallMsg().

The message is queued on the message port's list of messages according to its priority. Messages that have the same priority are queued on first come, first served basis.

Whether a message is standard or buffered is determined by the procedure you use to create the message: CreateMsg() creates a standard message (one whose message data belongs to the sending task; the receiving task reads from this block), while CreateBufferedMsg creates a buffered message (one in which a buffer for the message data is included in the message). For standard messages, the dataptr and datasize arguments refer to the data block owned by the message sender. For buffered messages, the dataptr and datasize arguments specify the data to be copied into the message's internal buffer before the message is sent.

If the message is a buffered message, SendMsg() checks the size of the data block to see whether it will fit in the message's buffer. If it won't fit, SendMsg() returns an error.

Arguments

mp
The item number of the message port to which to send the message.
msg
The item number of the message to send.
dataptr
A pointer to the message data, or NULL if there is no data to include in the message. For a standard message, the pointer specifies a data block owned by the sending task, which can later be read by the receiving task. For a buffered message, the pointer specifies a block of data to be copied into the message's internal data buffer.
datasize
The size of the message data, in bytes, or 0 if there is no data to include in the message.

Return Value

The procedure returns 0 if the message was sent successfully or an error code if an error occurs.

Implementation

SWI implemented in kernel folio V20.

Associated Files

msgport.h
ANSI C Prototype

See Also

GetMsg(), GetThisMsg(), ReplyMsg(), ReplySmallMsg(), SendSmallMsg(), WaitPort()