Skip to content
Snippets Groups Projects

Draft: Resolve "Unix Socket Server schreiben"

Merged Leon Dietrich requested to merge 3-unix-socket-server-schreiben into master
4 files
+ 35
34
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 0
25
@@ -13,31 +13,6 @@
namespace rmrf::net {
[[nodiscard]] socketaddr get_own_address_after_connect(const auto_fd& socket) {
socketaddr own_address;
socklen_t sa_local_len = sizeof(sockaddr_storage);
if (getsockname(socket.get(), own_address.ptr(), &sa_local_len) == 0) {
// Update length field after the internal structure was modified
// TODO: Maybe make this an internal method in socketaddr to update the size
own_address = own_address.ptr();
} else {
switch(errno) {
case EBADF:
case ENOTSOCK:
throw netio_exception("Invalid file descriptor provided to obtain own address. ERRNO: " + std::to_string(errno));
case EFAULT:
case EINVAL:
throw netio_exception("Invlid data structure for information retrival of own socket address provided. ERRNO: " + std::to_string(errno));
case ENOBUFS:
throw netio_exception("Kernel temporarily out of buffer space to store own address informatio.n ERRNO:." + std::to_string(errno));
default:
throw netio_exception("Unexpected error while requesting own socket address. ERRNO: " + std::to_string(errno));
}
}
return own_address;
}
[[nodiscard]] std::unique_ptr<udp_client> client_factory_construct_udp_client(const socketaddr& socket_identifier, connection_client::incomming_data_cb cb) {
const auto family = socket_identifier.family();
Loading