Webserv
Loading...
Searching...
No Matches
Socket.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <netdb.h>
4#include <string>
6
7namespace network {
8
9class Socket {
10public:
11 Socket();
12 Socket(int port);
13 Socket(std::string const &address, int port);
15 ~Socket();
16
17 int getFd(void) const;
18 const struct sockaddr_in &getAddr(void) const;
19 void bindTo(int port);
20 void bindTo(std::string const &address, int port);
21
22private:
23 sockaddr_in addr_;
24 int fd_;
25
26 void createAndBind(std::string const &ipAddress, int port);
27 Socket(Socket const &rhs);
28 Socket const &operator=(Socket const &rhs);
29};
30
31} // namespace network
Represents a single 'server' block from the configuration file.
Definition ServerBlock.hpp:18
~Socket()
Definition Socket.cpp:30
Socket const & operator=(Socket const &rhs)
Socket()
Definition Socket.cpp:11
const struct sockaddr_in & getAddr(void) const
Definition Socket.cpp:39
sockaddr_in addr_
Definition Socket.hpp:23
int fd_
Definition Socket.hpp:24
void bindTo(int port)
Definition Socket.cpp:43
Socket(Socket const &rhs)
int getFd(void) const
Definition Socket.cpp:35
void createAndBind(std::string const &ipAddress, int port)
Definition Socket.cpp:54
Definition Acceptor.hpp:8