[Previous]
[Contents]
[Next]

Sendfd()

send a message to a process associated with a file descriptor

Synopsis:

#include <sys/kernel.h>
int Sendfd( int fd,
            void *smsg, void *rmsg,
            unsigned snbytes, unsigned rnbytes );

Description:

The kernel function Sendfd() sends a message pointed to by smsg to the process associated with fd. Any reply is placed in the message buffer pointed to by rmsg. The maximum size of the sent message is snbytes, while the size of the reply is truncated to a maximum of rnbytes. The file descriptor fd must have been returned by a call to qnx_fd_attach() (which open() calls). The kernel uses the fd to index into the kernel file descriptor table and replace the fd with a process id. At this point the Sendfd() becomes equivalent to a Send().

This call is used heavily by the I/O library to direct messages to the appropriate resource manager based upon a file descriptor (for example, read()). You should only need to use it if you write your own resource manager that implements an extended set of messages not provided by the standard library.

The number of bytes transferred is the minimum of that specified by both the sender and the receiver. The send data isn't allowed to overflow the receive buffer area provided by the receiver, nor can the receiver read past the end of the sender's buffer.

After sending a message, the sending process becomes blocked, waiting for a reply. If the receiving process is receive-blocked and ready to receive the message, the transfer of data into its address space occurs immediately, the receiver is unblocked and made ready to run, and the sending process enters the REPLY BLOCKED state. If the receiver isn't ready to receive the message, the sender becomes SEND BLOCKED, and is placed in a queue (perhaps with other processes), and the transfer doesn't occur until the receiving task does a receive.

If specified process doesn't exist, or dies while the sender is BLOCKED on it then Sendfd() returns -1, and errno is set to ESRCH.

Sendfd() may be interrupted by a signal, in which case it returns -1, and errno is set to EINTR.

Sendfd() is a simple cover function that builds two single-part _mxfer_entry structures on the stack, and calls Sendfdmx(), which is the real kernel function. It's provided for convenience, since it's easier to use than Sendfdmx() for simple messages.

Returns:

0
Success.
-1
An error occurred. errno is set to indicate the error.

Errors:

EAGAIN
No more Process Manager to Network Manager queue packets available.
EBADF
The process fd doesn't exist.
EDSTFAULT
Destination would fault on a message pass.
EFAULT
In order to complete the message exchange, the current process would have incurred a segment violation. Your buffer(s) may be invalid or too small.
EHOSTUNREACH
The destination node isn't in the net mapping, or a physical I/O error occurred trying to communicate to the node.
EINTR
Call interrupted by a signal.
EINVAL
The virtual circuit buffer can't be grown due to an invalid message length.
ENOMEM
The virtual circuit buffer can't be grown because no memory is available.

Examples:

See Sendfdmx().

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

Caveats:

Sendfd() is a macro.

See also:

Creceive(), Creceivemx(), errno, Receive(), Receivemx(), Reply(), Replymx(), Readmsg(), Readmsgmx(), Send(), Sendfdmx(), Sendmx(), Writemsg(), Writemsgmx(), Trigger()


[Previous]
[Contents]
[Next]