URING++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
uringpp::socket Class Reference
Inheritance diagram for uringpp::socket:
Inheritance graph
[legend]
Collaboration diagram for uringpp::socket:
Collaboration graph
[legend]

Public Member Functions

int fd () const
 Get the file descriptor of the socket. More...
 
 socket (socket &&other) noexcept
 Move construct a new socket object. More...
 
 socket (std::shared_ptr< event_loop > loop, int domain, int type, int protocol)
 Construct a new socket object. More...
 
 socket (std::shared_ptr< event_loop > loop, int fd)
 Construct a new socket object from a file descriptor. More...
 
 ~socket ()
 Destroy the socket object. If the socket is still open, it will be closed. More...
 
task< void > close ()
 Close the socket. More...
 
sqe_awaitable read (void *buf, size_t count)
 Read data from the socket. More...
 
sqe_awaitable write (void const *buf, size_t count)
 Write data to the socket. More...
 
sqe_awaitable readv (struct iovec const *iov, int iovcnt)
 Vectorized read from the socket. More...
 
sqe_awaitable writev (struct iovec const *iov, int iovcnt)
 Vectorized write data to the socket. More...
 
sqe_awaitable read_fixed (void *buf, size_t count, int buf_index)
 Read data to a preregistered buffer from the socket. More...
 
sqe_awaitable write_fixed (void const *buf, size_t count, int buf_index)
 Write data from a preregistered buffer to the socket. More...
 
sqe_awaitable sendmsg (struct msghdr const *msg, int flags=0)
 Send messages to the socket. More...
 
sqe_awaitable recvmsg (struct msghdr *msg, int flags=0)
 Receive messages from the socket. More...
 
sqe_awaitable send (void const *buf, size_t len, int flags=0)
 Send data to the socket. More...
 
sqe_awaitable recv (void *buf, size_t len, int flags=0)
 Receive data from the socket. More...
 
sqe_awaitable shutdown (int how)
 Shutdown the socket. More...
 
sqe_awaitable tee (file const &out, size_t count, unsigned int flags)
 Tee the socket to a file. More...
 
sqe_awaitable tee (socket const &out, size_t count, unsigned int flags)
 Tee the socket to another socket. More...
 
sqe_awaitable splice_to (pipe const &out, size_t nbytes, unsigned flags)
 Splice the socket to a pipe. More...
 
sqe_awaitable splice_from (pipe const &in, size_t nbytes, unsigned flags)
 Splice from a pipe to the socket. More...
 
- Public Member Functions inherited from uringpp::noncopyable
 noncopyable (noncopyable &&)=default
 
 noncopyable (noncopyable const &)=delete
 
noncopyableoperator= (noncopyable const &)=delete
 
noncopyableoperator= (noncopyable &&)=default
 

Static Public Member Functions

static task< socketconnect (std::shared_ptr< event_loop > loop, std::string const &hostname, std::string const &port)
 Connect to a remote host. More...
 

Friends

class listener
 

Detailed Description

Examples
helloworld.cc.

Constructor & Destructor Documentation

◆ socket() [1/3]

uringpp::socket::socket ( socket &&  other)
inlinenoexcept

Move construct a new socket object.

Parameters
other

◆ socket() [2/3]

uringpp::socket::socket ( std::shared_ptr< event_loop loop,
int  domain,
int  type,
int  protocol 
)
inline

Construct a new socket object.

Parameters
loopThe event loop.
domainThe domain of the socket.
typeThe type of the socket.
protocolThe protocol of the socket.

◆ socket() [3/3]

uringpp::socket::socket ( std::shared_ptr< event_loop loop,
int  fd 
)
inline

Construct a new socket object from a file descriptor.

Parameters
loopThe event loop.
fdThe file descriptor.

◆ ~socket()

uringpp::socket::~socket ( )
inline

Destroy the socket object. If the socket is still open, it will be closed.

Member Function Documentation

◆ close()

task< void > uringpp::socket::close ( )
inline

Close the socket.

Returns
task<void>

◆ connect()

static task< socket > uringpp::socket::connect ( std::shared_ptr< event_loop loop,
std::string const &  hostname,
std::string const &  port 
)
inlinestatic

Connect to a remote host.

Parameters
loopThe event loop.
hostnameThe hostname of the remote host.
portThe port of the remote host.
Returns
task<socket> The socket object.
Examples
helloworld.cc.

◆ fd()

int uringpp::socket::fd ( ) const
inline

Get the file descriptor of the socket.

Returns
int The file descriptor of the socket.

◆ read()

sqe_awaitable uringpp::socket::read ( void *  buf,
size_t  count 
)
inline

Read data from the socket.

Parameters
bufThe buffer to read into.
countThe number of bytes to read.
Returns
sqe_awaitable

◆ read_fixed()

sqe_awaitable uringpp::socket::read_fixed ( void *  buf,
size_t  count,
int  buf_index 
)
inline

Read data to a preregistered buffer from the socket.

Parameters
bufThe preregistered buffer to read into.
countThe number of bytes to read.
buf_indexThe index of the preregistered buffer to read into.
Returns
sqe_awaitable

◆ readv()

sqe_awaitable uringpp::socket::readv ( struct iovec const *  iov,
int  iovcnt 
)
inline

Vectorized read from the socket.

Parameters
iovThe vector of buffers to read into.
iovcntThe number of buffers to read.
Returns
sqe_awaitable

◆ recv()

sqe_awaitable uringpp::socket::recv ( void *  buf,
size_t  len,
int  flags = 0 
)
inline

Receive data from the socket.

Parameters
bufThe buffer to receive into.
lenThe number of bytes to receive.
flagsThe flags to use.
Returns
sqe_awaitable

◆ recvmsg()

sqe_awaitable uringpp::socket::recvmsg ( struct msghdr *  msg,
int  flags = 0 
)
inline

Receive messages from the socket.

Parameters
msgThe messages to receive.
flagsThe flags to use.
Returns
sqe_awaitable

◆ send()

sqe_awaitable uringpp::socket::send ( void const *  buf,
size_t  len,
int  flags = 0 
)
inline

Send data to the socket.

Parameters
bufThe buffer to send.
lenThe number of bytes to send.
flagsThe flags to use.
Returns
sqe_awaitable

◆ sendmsg()

sqe_awaitable uringpp::socket::sendmsg ( struct msghdr const *  msg,
int  flags = 0 
)
inline

Send messages to the socket.

Parameters
msgThe messages to send.
flagsThe flags to use.
Returns
sqe_awaitable

◆ shutdown()

sqe_awaitable uringpp::socket::shutdown ( int  how)
inline

Shutdown the socket.

Parameters
howWhich sides of the socket to shutdown.
Returns
sqe_awaitable

◆ splice_from()

sqe_awaitable uringpp::socket::splice_from ( pipe const &  in,
size_t  nbytes,
unsigned  flags 
)
inline

Splice from a pipe to the socket.

Parameters
inThe pipe to splice from.
nbytesThe number of bytes to splice.
flagsThe flags to use.
Returns
sqe_awaitable

◆ splice_to()

sqe_awaitable uringpp::socket::splice_to ( pipe const &  out,
size_t  nbytes,
unsigned  flags 
)
inline

Splice the socket to a pipe.

Parameters
outThe pipe to splice to.
off_outThe offset to splice to.
nbytesThe number of bytes to splice.
flagsThe flags to use.
Returns
sqe_awaitable

◆ tee() [1/2]

sqe_awaitable uringpp::socket::tee ( file const &  out,
size_t  count,
unsigned int  flags 
)

Tee the socket to a file.

Parameters
outThe file to tee to.
countThe number of bytes to tee.
flagsThe flags to use.
Returns
sqe_awaitable

◆ tee() [2/2]

sqe_awaitable uringpp::socket::tee ( socket const &  out,
size_t  count,
unsigned int  flags 
)
inline

Tee the socket to another socket.

Parameters
outThe socket to tee to.
countThe number of bytes to tee.
flagsThe flags to use.
Returns
sqe_awaitable

◆ write()

sqe_awaitable uringpp::socket::write ( void const *  buf,
size_t  count 
)
inline

Write data to the socket.

Parameters
bufThe buffer to write from.
countThe number of bytes to write.
Returns
sqe_awaitable

◆ write_fixed()

sqe_awaitable uringpp::socket::write_fixed ( void const *  buf,
size_t  count,
int  buf_index 
)
inline

Write data from a preregistered buffer to the socket.

Parameters
bufThe preregistered buffer to write from.
countThe number of bytes to write.
buf_indexThe index of the preregistered buffer to write from.
Returns
sqe_awaitable

◆ writev()

sqe_awaitable uringpp::socket::writev ( struct iovec const *  iov,
int  iovcnt 
)
inline

Vectorized write data to the socket.

Parameters
iovThe iovec to write from.
iovcntThe number of iovecs to write.
Returns
sqe_awaitable

The documentation for this class was generated from the following file: