Repository navigation
Expand file tree
/
Copy pathsendmsg.2
More file actions
181 lines (181 loc) · 4.23 KB
/
Copy pathsendmsg.2
File metadata and controls
181 lines (181 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
.TH SENDMSG 2 2023-11-2 "Homa" "Linux Programmer's Manual"
.SH NAME
sendmsg \- send a Homa request or response message
.SH SYNOPSIS
.nf
.B #include <homa.h>
.PP
.BI "ssize_t sendmsg(int " sockfd ", const struct msghdr *" msg ", int " flags );
.fi
.SH DESCRIPTION
The
.B sendmsg
kernel call is used to send request and response messages on Homa sockets.
The
.I sockfd
argument must refer to a Homa socket. The
.I msg
argument describes the message to send and the destination where it
should be sent (more details below). The
.I flags
argument is not used for Homa messages.
.PP
The
.B msg
argument must point to a structure of the following type:
.PP
.in +4n
.ps -1
.vs -2
.EX
struct msghdr {
void *msg_name; /* Address of destination (sockaddr_in
* or sockaddr_in6).
socklen_t msg_namelen; /* Size of address. */
struct iovec *msg_iov; /* Message contents: one or more extents. */
size_t msg_iovlen; /* Number of elements in msg_iov. */
void *msg_control; /* Address of homa_sendmsg_args struct. */
size_t msg_controllen; /* Must always be zero (if not, sendmsg will
* fail with EINVAL, for arcane reasons). */
int msg_flags; /* Not used by Homa. */
};
.EE
.vs +2
.ps +1
.in
.PP
Homa requires additional information beyond what can be represented in a
.BR "struct msghdr" ,
so the
.B msg_control
field must refer to a structure of the following type:
.PP
.in +4n
.ps -1
.vs -2
.EX
struct homa_sendmsg_args {
uint64_t id; /* RPC identifier. */
__u64 completion_cookie; /* For requests only; value to return
* along with response. */
__u32 flags; /* OR'ed combination of bits. */
};
.EE
.vs +2
.ps +1
.in
.PP
If the
.B id
field of the
.B homa_sendmsg_args
is initially 0, then a new RPC will be created and a request message
will be sent as described by
.I msg\c
->\c
.B msg_name
and
.IR msg ->\c
.BR msg_iov ;
the
.B id
field will be overwritten with the identifier of the new RPC, which is
unique among all RPCs initiated via
.IR sockfd .
This identifier can be used to wait for the response with
.BR recvmsg .
If
.B id
is nonzero, then a response message will be sent for the RPC identified
uniquely by
.B id
and
.IR msg ->\c
.BR msg_name .
.PP
The
.B id
field of
.B homa_sendmsg_args
contains an OR'ed collection of bits. At present only a single
flag bit is supported.
.TP
.B HOMA_SENDMSG_PRIVATE
Ignored when sending responses
.RB ( id " is 0)."
For requests, this bit will mark the RPC as
.IR private .
The response for a
private RPC can only be retrieved by specifying the RPC's id explicitly
when invoking
.BR recvmsg .
In addition, system calls such as
.BR select (2)
cannot be used to determine when a private response has arrived.
.PP
.B sendmsg
returns as soon as the message has been queued for transmission.
.B sendmsg
will block if there are so many outstanding messages on the socket that
its limit on write buffer memory has been exceeded. However, if the
.BR MSG_DONTWAIT
bit is set in the
.BR flags
argument to
.BR sendmsg
or the
.B O_NONBLOCK
flag is set for the socket using
.BR fcntl
then
.B sendmsg
will will fail with an
.I errno
value of
.BR EAGAIN
instead of blocking.
.SH RETURN VALUE
The return value is 0 for success and -1 if an error occurred.
.SH ERRORS
.PP
When
.B sendmsg
returns an error,
.I errno
will have one of the following values:
.TP
.B EAFNOSUPPORT
The address family specified by
.I dest_addr
does not match the address family specified when the socket was opened
.RB ( AF_INET
or
.BR AF_INET6 ).
.TP
.B EBADF
.I sockfd
is not a valid open file descriptor.
.TP
.B EFAULT
An invalid user space address was specified for an argument.
.TP
.B EINVAL
The size of the request exceeded
.B HOMA_MAX_MESSAGE_LENGTH, or
.I sockfd
was not a Homa socket, or a nonzero completion cookie was specified
for a response message, or the
.B id
for a response message does not match an existing RPC for which a
request message has been received.
.TP
.B ENOMEM
Memory could not be allocated for internal data structures needed
for the message.
.TP
.B ESHUTDOWN
The socked has been disabled using
.BR shutdown (2).
.SH SEE ALSO
.BR recvmsg (2),
.BR homa (7)