VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gmsg.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
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( int , const void * , size_t , int ,
41  int fd_to_send = -1 ) ;
42  ///< A send() replacement using sendmsg().
43 
44  static ssize_t sendto( int , 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( int , void * , size_t , int ,
49  int * fd_received_p = nullptr ) ;
50  ///< A recv() replacement using recvmsg().
51 
52  static ssize_t recvfrom( int , void * , size_t , int , sockaddr * , socklen_t * ,
53  int * fd_received_p = nullptr ) ;
54  ///< A recvfrom() replacement using recvmsg().
55 
56  static bool fatal( int error ) ;
57  ///< Returns true if the error value indicates a permanent
58  ///< problem with the socket.
59 
60 private:
61  Msg() ;
62 } ;
63 
64 #endif
static ssize_t send(int, const void *, size_t, int, int fd_to_send=-1)
A send() replacement using sendmsg().
Definition: gmsg.cpp:32
static ssize_t sendto(int, const void *, size_t, int, const sockaddr *, socklen_t, int fd_to_send=-1)
A sendto() replacement using sendmsg().
Definition: gmsg.cpp:38
static ssize_t recvfrom(int, void *, size_t, int, sockaddr *, socklen_t *, int *fd_received_p=nullptr)
A recvfrom() replacement using recvmsg().
Definition: gmsg.cpp:82
Wrappers for sendmsg() and recvmsg() that are near drop-in replacements for send()/sendto() and recv(...
Definition: gmsg.h:37
static ssize_t recv(int, void *, size_t, int, int *fd_received_p=nullptr)
A recv() replacement using recvmsg().
Definition: gmsg.cpp:76
static bool fatal(int error)
Returns true if the error value indicates a permanent problem with the socket.
Definition: gmsg.cpp:119