Commit Graph

247 Commits

Author SHA1 Message Date
Max Kellermann
d3ef4ab234 net/FormatAddress: new library to replace ToString.cxx
This library writes to a caller-specified buffer instead of
allocating a std::string which can be faster by avoiding heap
allocations.
2024-07-05 18:38:17 +02:00
Max Kellermann
432bfa15f4 net/SocketError: move check to IsSocketError() 2024-06-25 20:29:27 +02:00
Max Kellermann
03b674ce73 net/meson.build: compile IPv[46]Address.cxx only if TCP is enabled 2024-05-06 12:57:55 +02:00
Max Kellermann
9c421997bf net/SocketDescriptor: WriteNoWait() uses MSG_NOSIGNAL 2024-05-06 12:55:02 +02:00
Max Kellermann
73509fc189 net/LocalSocketAddress: new class wrapping struct sockaddr_un 2024-05-06 12:54:45 +02:00
Max Kellermann
7c9b7fa311 net/SocketAddress: use std::string_view::find() instead of std::memchr() 2024-05-06 12:54:45 +02:00
Max Kellermann
cbba22c947 net/SocketAddress: include IPv[46]Address.hxx only ifdef HAVE_TCP 2024-05-06 12:50:44 +02:00
Max Kellermann
f8529d4fe6 net/{Allocated,Static}SocketAddress: inline GetLocalRaw() 2024-05-06 12:50:29 +02:00
Max Kellermann
2a206ef309 net/StaticSocketAddress: add method GetLocalPath() 2024-05-06 12:50:24 +02:00
Max Kellermann
6200c0dc46 net/StaticSocketAddress: include <string_view> only ifdef HAVE_UN 2024-05-06 12:50:19 +02:00
Max Kellermann
6830cf9dcf net/AllocatedSocketAddress: add SetLocal() overload with std::string_view 2024-05-06 12:48:42 +02:00
Max Kellermann
1e4bf90c60 io, net, evnet: quote file names in error messages 2024-04-10 13:36:05 +02:00
Max Kellermann
011b96ff98 net/UniqueSocketDescriptor: add method MoveToFileDescriptor() 2024-04-04 09:16:44 +02:00
Max Kellermann
9c68f24cfc net/SocketError: fix typo
Whoops.  This function has never been used.
2024-03-11 15:32:24 +01:00
Max Kellermann
be84b189dc util, io, net, ...: use "#pragma once" 2024-03-11 15:32:24 +01:00
Max Kellermann
b68c3b7f55 net/SocketDescriptor: disable msghdr methods on Windows 2024-01-18 15:44:44 +01:00
Max Kellermann
0fbed6dec1 net/SocketDescriptor: remove misplaced [[nodiscard]] 2024-01-18 15:44:43 +01:00
Max Kellermann
6f6cbeba80 net/SocketDescriptor: add Send()/Receive() overloads with iovec 2024-01-13 22:32:35 +01:00
Max Kellermann
974ed0166c net/SocketDescriptor: add sendmsg(), recvmsg() wrappers 2024-01-13 22:31:58 +01:00
Max Kellermann
a91920a8ff net/SocketDescriptor: pass span<byte> to Read()/Write() 2024-01-13 22:31:34 +01:00
Max Kellermann
7cd38dde09 net/SocketDescriptor: add [[nodiscard]] 2024-01-13 22:31:24 +01:00
Max Kellermann
7f439b01a3 net/SocketAddress: move code to IsInet() 2024-01-08 13:48:13 +01:00
Max Kellermann
0fd6f83766 net/StaticSocketAddress: add constexpr 2024-01-08 13:48:05 +01:00
Max Kellermann
b15b2125e2 net/AddressInfo: add methods IsInet(), IsTCP() 2024-01-08 13:47:59 +01:00
Max Kellermann
0dfd7e3d8c net/SocketDescriptor: SO_PROTOCOL is really Linux-specific 2023-11-25 23:03:30 +01:00
Max Kellermann
6dc708f53f net/SocketDescriptor: use method GetOption() internally 2023-11-25 21:58:17 +01:00
Max Kellermann
60033f3eb4 net/SocketDescriptor: add method GetProtocol() 2023-11-25 21:58:09 +01:00
Max Kellermann
1239e075b8 net/SocketDescriptor: add method GetIntOption() 2023-11-25 21:56:07 +01:00
Max Kellermann
491cc8f54d net/SocketDescriptor: add {Read,Write}NoWait()
It was surprising that Read() was non-blocking, but there was no
blocking version of it.  Let's make the non-blocking behavior explicit
and change Read() to be blocking.

In order to find existing callers easily with compiler errors, this
also refactors Read()/Write() to take a std::span parameter.
2023-09-27 11:39:55 +02:00
Max Kellermann
8ca6606323 net/SocketDescriptor: move code to Receive(), Send() 2023-09-27 10:16:21 +02:00
Max Kellermann
b36f5f1ec4 net/ToString: use #pragma once 2023-09-18 22:01:40 +02:00
Max Kellermann
592649d3f2 net/ToString: check family==AF_INET6 instead of looking for colons 2023-09-18 21:59:27 +02:00
Max Kellermann
9398599816 net/ToString: use libfmt 2023-09-18 21:58:55 +02:00
Max Kellermann
61c29473d3 net/ToString: append port only if it is non-zero 2023-09-18 11:11:00 +02:00
Max Kellermann
5fd2fc77f3 net/ToString: add null check 2023-09-18 11:08:16 +02:00
Max Kellermann
3eb0681e3d net/ToString: use SocketAddress::GetLocalRaw() 2023-09-18 10:54:52 +02:00
Max Kellermann
339b9f6e7b net/StaticSocketAddress: add method GetSteadyPart() 2023-09-11 21:27:12 +02:00
Max Kellermann
35cfa6efa3 net/StaticSocketAddress: add SocketAddress cast constructor 2023-09-11 21:27:12 +02:00
Max Kellermann
34ec024bf4 net/AllocatedSocketAddress: add method GetSteadyPart() 2023-09-11 21:27:12 +02:00
Max Kellermann
53ec02d5e9 net/SocketDescriptor: decouple from FileDescriptor on Windows
On Windows, a socket is not a file descriptor; it is a different beast
(and anyway, Windows doesn't have file descriptors).
2023-03-29 10:12:50 +02:00
Max Kellermann
148aca23be use SPDX IDs, replacing the long copyright headers 2023-03-06 14:59:48 +01:00
Max Kellermann
452400b7ef net/SocketAddress: remove __cpp_lib_span checks 2023-03-05 08:41:33 +01:00
Max Kellermann
d9b1f2fefa net/SocketAddress: add method HasPort() 2022-12-01 15:10:25 +01:00
Max Kellermann
fa58db798b lib/fmt/RuntimeError: new library
Replacing FormatRuntimeError().
2022-11-29 14:10:34 +01:00
Max Kellermann
bbc82a9892 io/FileDescriptor, net/SocketDescriptor: make lots of methods "const"
Only the file descriptor value itself is const, but the file itself
may be readable/writable.
2022-11-09 19:19:20 +01:00
Max Kellermann
cc0def15c4 Copyright year 2022 2022-07-14 17:59:35 +02:00
Max Kellermann
2ba092711f event/net/UdpListener: use IsSocketErrorReceiveWouldBlock() 2022-06-30 10:32:25 +02:00
Max Kellermann
8aa4227c0c net/SocketAddress: add std::span cast operators 2022-06-30 10:30:54 +02:00
Max Kellermann
bc3415ce8b Copyright year 2022 2022-06-30 09:41:53 +02:00
Max Kellermann
12d67dad35 net/SocketError: support ETIMEDOUT 2022-06-29 17:28:47 +02:00