RSOCKET(7)
πΈ NAME πΈ
rsocket β RDMA socket API. Hiiii bestie, you're reading rsocket(7) from the Librdmacm Programmer's Manual, and we're about to make this whole RDMA socket situation make sense. π
β¨ SYNOPSIS β¨
#include <rdma/rsocket.h>
π¦ DESCRIPTION π¦
Literally the RDMA socket API and protocol. That's the vibe.
π NOTES π
Okay so rsockets is a protocol over RDMA that supports a socket-level API for applications. The rsocket APIs are intended to match the behavior of corresponding socket calls, except where noted. Rsocket functions match the name and function signature of socket calls, with the one exception that all function calls are prefixed with an r. No cap.
Functions take the same parameters as that used for sockets. Here's the function roster, bestie:
rsocketrbind,rlisten,raccept,rconnectrshutdown,rcloserrecv,rrecvfrom,rrecvmsg,rread,rreadvrsend,rsendto,rsendmsg,rwrite,rwritevrpoll,rselectrgetpeername,rgetsocknamersetsockopt,rgetsockopt,rfcntlrepoll_create,repoll_ctl,repoll_wait
The capabilities and flags supported at this time are:
PF_INET,PF_INET6,SOCK_STREAM,SOCK_DGRAMSOL_SOCKETβSO_ERROR,SO_KEEPALIVE(flag supported, but ignored, bestie),SO_LINGER,SO_OOBINLINE,SO_RCVBUF,SO_REUSEADDR,SO_SNDBUFIPPROTO_TCPβTCP_NODELAY,TCP_MAXSEGIPPROTO_IPV6βIPV6_V6ONLYMSG_DONTWAIT,MSG_PEEK,O_NONBLOCK
Rsockets provides extensions beyond normal socket routines that allow for direct placement of data into an application's buffer. This is also known as zero-copy support, since data is sent and received directly, bypassing copies into network controlled buffers. The following calls and options support direct data placement: riomap, riounmap, riowrite.
π«Ά riomap
off_t riomap(int socket, void *buf, size_t len, int prot, int flags,
off_t offset)
riomap registers an application buffer with the RDMA hardware associated with an rsocket. The buffer is registered either for local only access (PROT_NONE) or for remote write access (PROT_WRITE). When registered for remote access, the buffer is mapped to a given offset. The offset is either provided by the user, or if the user selects -1 for the offset, rsockets selects one. The remote peer may access an iomapped buffer directly by specifying the correct offset.
β οΈ The mapping is not guaranteed to be available until after the remote peer receives a data transfer initiated after riomap has completed.
In order to enable the use of remote IO mapping calls on an rsocket, an application must set the number of IO mappings that are available to the remote peer. This may be done using the rsetsockopt RDMA_IOMAPSIZE option. By default, an rsocket does not support remote IO mappings.
π riounmap
int riounmap(int socket, void *buf, size_t len)
riounmap removes the mapping between a buffer and an rsocket. Simple as that.
π riowrite
size_t riowrite(int socket, const void *buf, size_t count, off_t offset,
int flags)
riowrite allows an application to transfer data over an rsocket directly into a remotely iomapped buffer. The remote buffer is specified through an offset parameter, which corresponds to a remote iomapped buffer. From the sender's perspective, riowrite behaves similar to rwrite. From a receiver's view, riowrite transfers are silently redirected into a pre-determined data buffer. Data is received automatically, and the receiver is not informed of the transfer.
However, iowrite data is still considered part of the data stream, such that iowrite data will be written before a subsequent transfer is received. A message sent immediately after initiating an iowrite may be used to notify the receiver of the iowrite.
In addition to standard socket options, rsockets supports options specific to RDMA devices and protocols. These options are accessible through rsetsockopt using SOL_RDMA option level.
RDMA_SQSIZEβ integer size of the underlying send queue.RDMA_RQSIZEβ integer size of the underlying receive queue.RDMA_INLINEβ integer size of inline data.RDMA_IOMAPSIZEβ integer number of remote IO mappings supported.RDMA_ROUTEβstruct ibv_path_dataof path record for connection.
π¨ Important vibe check: note that rsockets fd's cannot be passed into non-rsocket calls.
For applications which must mix rsocket fd's with standard socket fd's or opened files, rpoll and rselect support polling both rsockets and normal fd's. Iconic, honestly.
Existing applications can make use of rsockets through the use of a preload library. Because rsockets implements an end-to-end protocol, both sides of a connection must use rsockets. The rdma_cm library provides such a preload library, librspreload. To reduce the chance of the preload library intercepting calls without the user's explicit knowledge, the librspreload library is installed into %libdir%/rsocket subdirectory.
The preload library can be used by setting LD_PRELOAD when running.
π Note that not all applications will work with rsockets. Support is limited based on the socket options used by the application. Support for fork() is limited, but available.
To use rsockets with the preload library for applications that call fork, users must set the environment variable RDMAV_FORK_SAFE=1 on both the client and server side of the connection. In general, fork is supportable for server applications that accept a connection, then fork off a process to handle the new connection.
Rsockets uses configuration files that give an administrator control over the default settings used by rsockets. Use files under /etc/rdma/rsocket as shown:
mem_defaultβ default size of receive buffer(s)wmem_defaultβ default size of send buffer(s)sqsize_defaultβ default size of send queuerqsize_defaultβ default size of receive queueinline_defaultβ default size of inline dataiomap_sizeβ default size of remote iomapping tablepolling_timeβ default number of microseconds to poll for data before waitingwake_up_intervalβ maximum number of milliseconds to block in poll. This value is used to safe guard against potential application hangs inrpoll().max_eventsβ maximum number of events for the epoll thread to handle for anepoll_instance.
All configuration files should contain a single integer value. Values may be set by issuing a command similar to the following example:
echo 1000000 > /etc/rdma/rsocket/mem_default
If configuration files are not available, rsockets uses internal defaults. Applications can override default values programmatically through the rsetsockopt routine.
π SEE ALSO π
π That's the whole page, bestie. Brought to you by librdmacm, dated 2026-04-13, and filed under RSOCKET(7). Go slay those sockets. π
π¦ where this page comes from
- arch rolling: rdma-core 65.0-1 Β· GPL-2.0-or-later OR LicenseRef-OpenIB.org-BSD-MIT AND GPL-2.0-or-later OR LicenseRef-OpenIB.org-BSD-FreeBSD AND GPL-2.0-or-later OR LicenseRef-Intel-BSD-3-Clause AND GPL-2.0-or-later OR LicenseRef-PathScale-BSD-Patent-License AND CC0-1.0 AND MIT AND BSD-2-Clause AND CPL-1.0 OR BSD-2-Clause OR GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms