1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include <string>
- #include <cstring>
- #include <vector>
- #include <iostream>
- #include <exception>
- #include <cmath>
- #include <stdexcept>
- #include <sys/socket.h>
- #include <netinet/in.h>
- class cppsocket{
- private:
- struct sockaddr_in serv_addr;
- int sock;
- std::vector<char> buffer;
- public:
- const static constexpr unsigned int buffersize = 1024;
- cppsocket(sockaddr_in _serv_addr, int _sock);
- cppsocket();
- cppsocket(const std::string& addr, unsigned int PORT);
- void write(const std::string& message);
- void write(const std::vector<char>& message);
- std::vector<char> receive();
- };
- class server_socket{
- private:
- int port_;
- int server_fd;
- struct sockaddr_in address;
- socklen_t addrlen;
- public:
- int port();
- server_socket(int _port);
- cppsocket accept_connection();
- };
|