E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gmsg.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 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() that 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 * , size_t , int ,
41 int fd_to_send = -1 ) ;
42 ///< A send() replacement using sendmsg().
43
44 static ssize_t sendto( SOCKET , const void * , size_t , int , const sockaddr * , socklen_t ,
45 int fd_to_send = -1 ) ;
46 ///< A sendto() replacement using sendmsg().
47
48 static ssize_t recv( SOCKET , void * , size_t , int ) ;
49 ///< A recv() wrapper.
50
51 static ssize_t recv( SOCKET , void * , size_t , int , int * fd_received_p ) ;
52 ///< A recv() replacement using recvmsg().
53
54 static ssize_t recvfrom( SOCKET , void * , size_t , int , sockaddr * , socklen_t * ,
55 int * fd_received_p = nullptr ) ;
56 ///< A recvfrom() replacement using recvmsg().
57
58 static bool fatal( int error ) ;
59 ///< Returns true if the error value indicates a permanent
60 ///< problem with the socket.
61
62 private:
63 Msg() ;
64 } ;
65
66 #endif
G::Msg::recv
static ssize_t recv(SOCKET, void *, size_t, int)
A recv() wrapper.
Definition: gmsg_unix.cpp:76
G::Msg::recvfrom
static ssize_t recvfrom(SOCKET, void *, size_t, int, sockaddr *, socklen_t *, int *fd_received_p=nullptr)
A recvfrom() replacement using recvmsg().
Definition: gmsg_unix.cpp:87
G::Msg::send
static ssize_t send(SOCKET, const void *, size_t, int, int fd_to_send=-1)
A send() replacement using sendmsg().
Definition: gmsg_unix.cpp:32
G::Msg::sendto
static ssize_t sendto(SOCKET, const void *, size_t, int, const sockaddr *, socklen_t, int fd_to_send=-1)
A sendto() replacement using sendmsg().
Definition: gmsg_unix.cpp:38
G
Low-level classes.
Definition: garg.h:29
G::Msg
Wrappers for sendmsg() and recvmsg() that are near drop-in replacements for send()/sendto() and recv(...
Definition: gmsg.h:37
G::Msg::fatal
static bool fatal(int error)
Returns true if the error value indicates a permanent problem with the socket.
Definition: gmsg_unix.cpp:124