libcosmos
Linux C++ System Programming Library
Loading...
Searching...
No Matches
UnixConnection.hxx
1#pragma once
2
3// cosmos
4#include <cosmos/net/Socket.hxx>
5#include <cosmos/net/types.hxx>
6#include <cosmos/net/UnixAddress.hxx>
7#include <cosmos/net/UnixOptions.hxx>
8
9namespace cosmos {
10
13 public Socket {
14public: // functions
15
16 explicit UnixConnection(FileDescriptor fd, const AutoCloseFD auto_close = AutoCloseFD{true}) :
17 Socket{fd, auto_close} {
18 }
19
20 auto unixOptions() {
21 return UnixOptions{this->m_fd};
22 }
23
24 auto unixOptions() const {
25 return UnixOptions{this->m_fd};
26 }
27
28 using Socket::receive;
29 using Socket::send;
30
31 void sendMessage(SendMessageHeader &header) {
32 return Socket::sendMessage(header);
33 }
34
35 Socket::AddressFilledIn receiveMessage(ReceiveMessageHeader &header) {
36 return Socket::receiveMessage(header);
37 }
38};
39
40} // end ns
41
FileDescriptor fd() const
Allows access to the underlying fd with const semantics.
Definition FileBase.hxx:74
Thin Wrapper around OS file descriptors.
Wrapper for struct msghdr for receiving message via Socket::receiveMessage().
Wrapper for struct msghdr for sending messages via Socket::sendMessage().
Base class for Socket types with ownership of a FileDescriptor.
Definition Socket.hxx:38
void sendMessage(SendMessageHeader &header, const SocketAddress *addr=nullptr)
Sends a message over the socket using extended SendMessageHeader data.
Definition Socket.cxx:126
AddressFilledIn receiveMessage(ReceiveMessageHeader &header, SocketAddress *addr=nullptr)
Receives a message from the socket using extended ReceiveMessageHeader data.
Definition Socket.cxx:145
size_t receive(void *buf, size_t length, const MessageFlags flags=MessageFlags{})
Receive data from the socket, using specific receive flags.
Definition Socket.cxx:84
size_t send(const void *buf, size_t length, const MessageFlags flags=MessageFlags{})
Send the given data over the socket, using specific send flags.
Definition Socket.cxx:66
An active UNIX domain socket connection.
UnixSocket level option setter/getter helper.