| 64 | |
| 65 | #pragma GCC diagnostic ignored "-Wold-style-cast" |
| 66 | void LCDConnection::connect(const string &host, const int port) { |
| 67 | if (!isValid()) { |
| 68 | throw LCDException(LCD_SOCKET_CREATION_ERROR); |
| 69 | } |
| 70 | |
| 71 | _addr.sin_family = AF_INET; |
| 72 | _addr.sin_port = htons(port); |
| 73 | |
| 74 | int status = inet_pton(AF_INET, host.c_str(), &_addr.sin_addr); |
| 75 | |
| 76 | if (errno == EAFNOSUPPORT) { |
| 77 | throw LCDException(LCD_SOCKET_NOT_SUPPORTED); |
| 78 | } |
| 79 | |
| 80 | status = ::connect(_sock, reinterpret_cast<struct sockaddr*>(&_addr), sizeof(_addr) ); |
| 81 | |
| 82 | if (status != 0) { |
| 83 | throw LCDException(LCD_SOCKET_CONNECTION_ERROR); |
| 84 | } |
| 85 | |
| 86 | _isConnected = true; |
| 87 | } |
| 88 | #pragma GCC diagnostic error "-Wold-style-cast" |
| 89 | |
| 90 | void LCDConnection::disconnect() { |
no test coverage detected