OpenVPN 3 Core Library
Loading...
Searching...
No Matches
write.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
#ifndef OPENVPN_COMMON_WRITE_H
13
#define OPENVPN_COMMON_WRITE_H
14
15
#include <unistd.h>
16
#include <stdlib.h>
// defines std::abort()
17
18
namespace
openvpn
{
19
// like posix write() but retry if full buffer is not written
20
inline
ssize_t
write_retry
(
int
fd,
const
void
*buf,
size_t
count)
21
{
22
size_t
total = 0;
23
while
(
true
)
24
{
25
const
ssize_t status = ::write(fd, buf, count);
26
if
(status < 0)
27
return
status;
28
if
(
static_cast<
size_t
>
(status) > count)
// should never happen
29
std::abort();
30
total += status;
31
count -= status;
32
if
(!count)
33
break
;
34
buf =
static_cast<
const
unsigned
char
*
>
(buf) + status;
35
}
36
return
total;
37
}
38
}
// namespace openvpn
39
40
#endif
openvpn
Support deferred server-side state creation when client connects.
Definition
ovpncli.cpp:95
openvpn::write_retry
ssize_t write_retry(int fd, const void *buf, size_t count)
Definition
write.hpp:20
openvpn
common
write.hpp
Generated by
1.9.8