E-MailRelay
gmsg_mac.cpp
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 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_mac.cpp
19///
20
21#include "gdef.h"
22#include "gmsg.h"
23#include <cerrno> // EINTR etc
24#include <sys/types.h>
25#include <sys/socket.h>
26
27ssize_t G::Msg::send( int fd , const void * buffer , std::size_t size , int flags ) noexcept
28{
29 return sendto( fd , buffer , size , flags , nullptr , 0U ) ;
30}
31
32ssize_t G::Msg::sendto( int fd , const void * buffer , std::size_t size , int flags ,
33 const sockaddr * address_p , socklen_t address_n ) noexcept
34{
35 return ::sendto( fd , buffer , size , flags|MSG_NOSIGNAL , // NOLINT
36 const_cast<sockaddr*>(address_p) , address_n ) ;
37}
38
39ssize_t G::Msg::recv( int fd , void * buffer , std::size_t size , int flags ) noexcept
40{
41 return ::recv( fd , buffer , size , flags ) ;
42}
43
44ssize_t G::Msg::recvfrom( int fd , void * buffer , std::size_t size , int flags ,
45 sockaddr * address_p , socklen_t * address_np ) noexcept
46{
47 return ::recvfrom( fd , buffer , size , flags , address_p , address_np ) ;
48}
49
50bool G::Msg::fatal( int error ) noexcept
51{
52 return !(
53 error == 0 ||
54 error == EAGAIN ||
55 error == EINTR ||
56 error == EMSGSIZE || // moot
57 error == ENOBUFS ||
58 error == ENOMEM ) ;
59}
60
static ssize_t recv(SOCKET, void *, std::size_t, int flags) noexcept
A recv() wrapper.
Definition: gmsg_mac.cpp:39
static bool fatal(int error) noexcept
Returns true if the error value indicates a permanent problem with the socket.
Definition: gmsg_mac.cpp:50
static ssize_t send(SOCKET, const void *, std::size_t, int flags) noexcept
A send() wrapper.
Definition: gmsg_mac.cpp:27
static ssize_t sendto(SOCKET, const void *, std::size_t, int flags, const sockaddr *, socklen_t) noexcept
A sendto() wrapper.
Definition: gmsg_mac.cpp:32
static ssize_t recvfrom(SOCKET, void *, std::size_t, int, sockaddr *, socklen_t *) noexcept
A recvfrom() wrapper.
Definition: gmsg_mac.cpp:44