123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include <string>
- #include <cstring>
- #include <vector>
- #include <iostream>
- #include <exception>
- #include <cmath>
- #include <stdexcept>
- #include <stdio.h>
- #include <sys/socket.h>
- #include <stdlib.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 = 16;
- cppsocket(sockaddr_in _serv_addr,int _sock);
- cppsocket();
- cppsocket(const std::string& addr, unsigned int PORT);
- void write(const std::string& 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();
- };
|