E-MailRelay

gmsg.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gmsg.h
19///
20
21#ifndef G_MSG_H
22#define G_MSG_H
23
24#include "gdef.h"
25
26 namespace G
27{
28 class Msg ;
29}
30
31//| \class G::Msg
32/// Wrappers for sendmsg() and recvmsg(). These are near drop-in replacements for
33/// send()/sendto() and recv()/recvto(), but with SIGPIPE disabled and optional
34/// file-descriptor-passing capabilities.
35/// \see man unix(7) and man cmsg(3)
36///
37 class G::Msg
38{
39 public:
40 static ssize_t send( SOCKET , const void * , std::size_t , int flags ) noexcept ;
41 ///< A send() replacement using sendmsg().
42
43 static ssize_t sendto( SOCKET , const void * , std::size_t , int flags ,
44 const sockaddr * , socklen_t ) noexcept ;
45 ///< A sendto() replacement using sendmsg().
46
47 static ssize_t recv( SOCKET , void * , std::size_t , int flags ) ;
48 ///< A recv() wrapper.
49
50 static ssize_t recvfrom( SOCKET , void * , std::size_t , int flags ,
51 sockaddr * , socklen_t * ) ;
52 ///< A recvfrom() replacement using recvmsg().
53
54 static bool fatal( int error ) noexcept ;
55 ///< Returns true if the error value indicates a permanent
56 ///< problem with the socket.
57
58 public:
59 Msg() = delete ;
60} ;
61
62#endif
G::Msg
Wrappers for sendmsg() and recvmsg().
Definition: gmsg.h:38
G::Msg::recvfrom
static ssize_t recvfrom(SOCKET, void *, std::size_t, int flags, sockaddr *, socklen_t *)
A recvfrom() replacement using recvmsg().
Definition: gmsg_unix.cpp:50
G::Msg::recv
static ssize_t recv(SOCKET, void *, std::size_t, int flags)
A recv() wrapper.
Definition: gmsg_unix.cpp:45
G::Msg::fatal
static bool fatal(int error) noexcept
Returns true if the error value indicates a permanent problem with the socket.
Definition: gmsg_unix.cpp:56
G::Msg::send
static ssize_t send(SOCKET, const void *, std::size_t, int flags) noexcept
A send() replacement using sendmsg().
Definition: gmsg_unix.cpp:34
G::Msg::sendto
static ssize_t sendto(SOCKET, const void *, std::size_t, int flags, const sockaddr *, socklen_t) noexcept
A sendto() replacement using sendmsg().
Definition: gmsg_unix.cpp:39
G
Low-level classes.
Definition: galign.h:28