Skip to content

Commit 008dc40

Browse files
lorenteymilseman
authored andcommitted
Doc updates
1 parent 84846f7 commit 008dc40

File tree

2 files changed

+50
-18
lines changed

2 files changed

+50
-18
lines changed

Sources/System/Sockets/SocketMessages.swift

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,16 @@ extension SocketDescriptor.AncillaryMessageBuffer.Message {
387387
extension SocketDescriptor {
388388
/// Send a message from a socket.
389389
///
390-
/// TODO: describe every parameter and option.
390+
/// - Parameters:
391+
/// - buffer: The region of memory that contains the data being sent.
392+
/// - recipient: The socket address of the recipient.
393+
/// - ancillary: A buffer of ancillary/control messages.
394+
/// - flags: see `send(2)`
395+
/// - retryOnInterrupt: Whether to retry the send operation
396+
/// if it throws ``Errno/interrupted``.
397+
/// The default is `true`.
398+
/// Pass `false` to try only once and throw an error upon interruption.
399+
/// - Returns: The number of bytes that were sent.
391400
///
392401
/// The corresponding C function is `sendmsg`.
393402
@_alwaysEmitIntoClient
@@ -453,7 +462,17 @@ extension SocketDescriptor {
453462
extension SocketDescriptor {
454463
/// Receive a message from a socket.
455464
///
456-
/// TODO: describe every parameter and option.
465+
/// - Parameters:
466+
/// - buffer: The region of memory to receive into.
467+
/// - flags: see `recv(2)`
468+
/// - ancillary: A buffer of ancillary messages. On return, `receive`
469+
/// overwrites the contents with received ancillary messages (if any).
470+
/// - retryOnInterrupt: Whether to retry the receive operation
471+
/// if it throws ``Errno/interrupted``.
472+
/// The default is `true`.
473+
/// Pass `false` to try only once and throw an error upon interruption.
474+
/// - Returns: The number of bytes that were received, and the flags that
475+
/// describe the received message.
457476
///
458477
/// The corresponding C function is `recvmsg`.
459478
@_alwaysEmitIntoClient
@@ -474,7 +493,20 @@ extension SocketDescriptor {
474493

475494
/// Receive a message from a socket.
476495
///
477-
/// TODO: describe every parameter and option.
496+
/// - Parameters:
497+
/// - buffer: The region of memory to receive into.
498+
/// - flags: see `recv(2)`
499+
/// - sender: A socket address with enough capacity to hold an
500+
/// address for the current socket domain/type. On return, `receive`
501+
/// overwrites the contents with the address of the remote client.
502+
/// - ancillary: A buffer of ancillary messages. On return, `receive`
503+
/// overwrites the contents with received ancillary messages (if any).
504+
/// - retryOnInterrupt: Whether to retry the receive operation
505+
/// if it throws ``Errno/interrupted``.
506+
/// The default is `true`.
507+
/// Pass `false` to try only once and throw an error upon interruption.
508+
/// - Returns: The number of bytes that were received, and the flags that
509+
/// describe the received message.
478510
///
479511
/// The corresponding C function is `recvmsg`.
480512
@_alwaysEmitIntoClient

Sources/System/Sockets/SocketOperations.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extension SocketDescriptor {
7979
nothingOrErrno(system_listen(self.rawValue, CInt(backlog)))
8080
}
8181

82-
/// Send a message from a socket
82+
/// Send a message from a socket.
8383
///
8484
/// - Parameters:
8585
/// - buffer: The region of memory that contains the data being sent.
@@ -90,7 +90,7 @@ extension SocketDescriptor {
9090
/// Pass `false` to try only once and throw an error upon interruption.
9191
/// - Returns: The number of bytes that were sent.
9292
///
93-
/// The corresponding C function is `send`
93+
/// The corresponding C function is `send`.
9494
@_alwaysEmitIntoClient
9595
public func send(
9696
_ buffer: UnsafeRawBufferPointer,
@@ -111,7 +111,7 @@ extension SocketDescriptor {
111111
}
112112
}
113113

114-
/// Send a message from a socket
114+
/// Send a message from a socket.
115115
///
116116
/// - Parameters:
117117
/// - buffer: The region of memory that contains the data being sent.
@@ -123,7 +123,7 @@ extension SocketDescriptor {
123123
/// Pass `false` to try only once and throw an error upon interruption.
124124
/// - Returns: The number of bytes that were sent.
125125
///
126-
/// The corresponding C function is `sendto`
126+
/// The corresponding C function is `sendto`.
127127
@_alwaysEmitIntoClient
128128
public func send(
129129
_ buffer: UnsafeRawBufferPointer,
@@ -159,7 +159,7 @@ extension SocketDescriptor {
159159
}
160160
}
161161

162-
/// Receive a message from a socket
162+
/// Receive a message from a socket.
163163
///
164164
/// - Parameters:
165165
/// - buffer: The region of memory to receive into.
@@ -170,7 +170,7 @@ extension SocketDescriptor {
170170
/// Pass `false` to try only once and throw an error upon interruption.
171171
/// - Returns: The number of bytes that were received.
172172
///
173-
/// The corresponding C function is `recv`
173+
/// The corresponding C function is `recv`.
174174
@_alwaysEmitIntoClient
175175
public func receive(
176176
into buffer: UnsafeMutableRawBufferPointer,
@@ -193,18 +193,21 @@ extension SocketDescriptor {
193193
}
194194
}
195195

196-
/// Receive a message from a socket
196+
/// Receive a message from a socket.
197197
///
198198
/// - Parameters:
199199
/// - buffer: The region of memory to receive into.
200200
/// - flags: see `recv(2)`
201+
/// - sender: A socket address with enough capacity to hold an
202+
/// address for the current socket domain/type. On return, `receive`
203+
/// overwrites the contents with the address of the remote client.
201204
/// - retryOnInterrupt: Whether to retry the receive operation
202205
/// if it throws ``Errno/interrupted``.
203206
/// The default is `true`.
204207
/// Pass `false` to try only once and throw an error upon interruption.
205208
/// - Returns: The number of bytes that were received.
206209
///
207-
/// The corresponding C function is `recvfrom`
210+
/// The corresponding C function is `recvfrom`.
208211
@_alwaysEmitIntoClient
209212
public func receive(
210213
into buffer: UnsafeMutableRawBufferPointer,
@@ -289,12 +292,9 @@ extension SocketDescriptor {
289292
}
290293
}
291294

292-
// TODO: acceptAndSockaddr or something that (tries to) returns the sockaddr
293-
// at least, for sockaddrs up to some sane length
294-
295-
/// Bind a name to a socket
295+
/// Bind a name to a socket.
296296
///
297-
/// The corresponding C function is `bind`
297+
/// The corresponding C function is `bind`.
298298
@_alwaysEmitIntoClient
299299
public func bind(to address: SocketAddress) throws {
300300
try _bind(to: address).get()
@@ -308,9 +308,9 @@ extension SocketDescriptor {
308308
return nothingOrErrno(success)
309309
}
310310

311-
/// Initiate a connection on a socket
311+
/// Initiate a connection on a socket.
312312
///
313-
/// The corresponding C function is `connect`
313+
/// The corresponding C function is `connect`.
314314
@_alwaysEmitIntoClient
315315
public func connect(to address: SocketAddress) throws {
316316
try _connect(to: address).get()

0 commit comments

Comments
 (0)