Skip to content

Commit ea4ba19

Browse files
committed
Added notification of connection availability
1 parent 96dcf01 commit ea4ba19

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

server/Server.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,33 @@ namespace simpleApp
193193
isFailed = true;
194194
}
195195
else
196-
{
197-
if (masterTcpSocket != -1 && addToEPoll(epollfd, masterTcpSocket, &masterTcpSocket, EPOLLIN | EPOLLET) == -1)
196+
{
197+
if (masterTcpSocket != -1)
198198
{
199-
std::cout << "EPOLL_CTL_ADD of TCP master socket failed with code " << errno << std::endl << std::flush;
200-
shutdown(masterTcpSocket, SHUT_RDWR);
201-
close(masterTcpSocket);
202-
masterTcpSocket = -1;
199+
if (addToEPoll(epollfd, masterTcpSocket, &masterTcpSocket, EPOLLIN | EPOLLET) == -1)
200+
{
201+
std::cout << "EPOLL_CTL_ADD of TCP master socket failed with code " << errno << std::endl << std::flush;
202+
shutdown(masterTcpSocket, SHUT_RDWR);
203+
close(masterTcpSocket);
204+
masterTcpSocket = -1;
205+
}
206+
else
207+
std::cout << "TCP-connection enabled" << std::endl;
203208
}
204209

205-
if (masterUdpSocket != -1 && addToEPoll(epollfd, masterUdpSocket, &masterUdpSocket, EPOLLIN | EPOLLET) == -1)
210+
if (masterUdpSocket != -1)
206211
{
207-
std::cout << "EPOLL_CTL_ADD of UDP master socket failed with code " << errno << std::endl << std::flush;
208-
shutdown(masterUdpSocket, SHUT_RDWR);
209-
close(masterUdpSocket);
210-
masterUdpSocket = -1;
212+
if (addToEPoll(epollfd, masterUdpSocket, &masterUdpSocket, EPOLLIN | EPOLLET) == -1)
213+
{
214+
std::cout << "EPOLL_CTL_ADD of UDP master socket failed with code " << errno << std::endl << std::flush;
215+
shutdown(masterUdpSocket, SHUT_RDWR);
216+
close(masterUdpSocket);
217+
masterUdpSocket = -1;
218+
}
219+
else
220+
std::cout << "UDP-connection enabled" << std::endl;
211221
}
212-
222+
213223
if (masterTcpSocket == -1 && masterUdpSocket == -1)
214224
{
215225
std::cout << "There are no master sockets linked to epoll object" << std::endl << std::flush;

0 commit comments

Comments
 (0)