MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / connect

Method connect

src/server/lcdapi/api/LCDConnection.cpp:66–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65#pragma GCC diagnostic ignored "-Wold-style-cast"
66void 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
90void LCDConnection::disconnect() {

Callers 1

LCDClientMethod · 0.80

Calls 2

LCDExceptionClass · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected