13 #ifndef __PROCESS_NETWORK_HPP__ 14 #define __PROCESS_NETWORK_HPP__ 33 sockaddr_storage storage;
34 socklen_t length =
sizeof(storage);
48 sockaddr_storage storage =
address;
50 const socklen_t address_size =
static_cast<socklen_t
>(address.
size());
51 if (
net::bind(s, (sockaddr*) &storage, address_size) < 0) {
62 sockaddr_storage storage =
address;
64 const socklen_t address_size =
static_cast<socklen_t
>(address.
size());
65 if (
net::connect(s, (sockaddr*) &storage, address_size) < 0) {
81 sockaddr_storage storage;
82 socklen_t length =
sizeof(storage);
84 if (::getsockname(s, (sockaddr*)&storage, &length) < 0) {
100 sockaddr_storage storage;
101 socklen_t length =
sizeof(storage);
103 if (::getpeername(s, (sockaddr*)&storage, &length) < 0) {
113 #endif // __PROCESS_NETWORK_HPP__ Try< int_fd > socket(int family, int type, int protocol)
Definition: socket.hpp:43
Definition: nothing.hpp:16
Try< Address > address(int_fd s)
Returns the Address with the assigned ip and assigned port.
Definition: network.hpp:79
Definition: address.hpp:324
Definition: errorbase.hpp:50
int bind(const int_fd &fd, const sockaddr *addr, socklen_t addrlen)
Definition: socket.hpp:143
size_t size() const
Definition: address.hpp:455
static Try< Address > create(const sockaddr_storage &storage, Option< socklen_t > length=None())
Definition: address.hpp:344
ErrnoError SocketError
Definition: error.hpp:33
int_fd accept(const int_fd &fd, sockaddr *addr, socklen_t *addrlen)
Definition: socket.hpp:132
Try< int_fd > accept(int_fd s)
Definition: network.hpp:31
Try< Nothing, SocketError > connect(int_fd s, const Address &address)
Definition: network.hpp:60
Definition: executor.hpp:48
Try< Address > peer(int_fd s)
Returns the peer's Address for the accepted or connected socket.
Definition: network.hpp:98
int connect(const int_fd &fd, const sockaddr *address, socklen_t addrlen)
Definition: socket.hpp:151
Try< Nothing > bind(int_fd s, const Address &address)
Definition: network.hpp:46
int int_fd
Definition: int_fd.hpp:35
std::string stringify(int flags)