Skip to content

Commit da7f3f0

Browse files
committed
Added keywords to prevent, unexpected behaviour
1 parent 1bc2c9c commit da7f3f0

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

easysocket/include/basesocket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class EASYSOCKET_API BaseSocket
3535
sockaddr_in address;
3636
bool isClosed = false;
3737

38-
BaseSocket(FDR_ON_ERROR, SocketType sockType = TCP, int socketId = -1);
38+
explicit BaseSocket(FDR_ON_ERROR, SocketType sockType = TCP, int socketId = -1);
3939

40-
void Close();
40+
virtual void Close();
4141

4242
std::string remoteAddress();
4343
int remotePort();

easysocket/include/tcpserver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class EASYSOCKET_API TCPServer : public BaseSocket
1414
// Event Listeners:
1515
std::function<void(TCPSocket *)> onNewConnection = [](TCPSocket* sock){FDR_UNUSED(sock)};
1616

17-
TCPServer(FDR_ON_ERROR);
17+
explicit TCPServer(FDR_ON_ERROR);
1818

1919
// Binding the server.
2020
void Bind(int port, FDR_ON_ERROR);
@@ -24,7 +24,7 @@ class EASYSOCKET_API TCPServer : public BaseSocket
2424
void Listen(FDR_ON_ERROR);
2525

2626
// Overriding Close to add shutdown():
27-
void Close();
27+
void Close() override;
2828

2929
private:
3030
static void Accept(TCPServer *server, FDR_ON_ERROR);

easysocket/include/tcpsocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class EASYSOCKET_API TCPSocket : public BaseSocket
1717
std::function<void(std::string)> onMessageReceived = [](std::string msg) { FDR_UNUSED(msg) };
1818
std::function<void()> onSocketClosed = [](){};
1919

20-
TCPSocket(FDR_ON_ERROR, int socketId = -1);
20+
explicit TCPSocket(FDR_ON_ERROR, int socketId = -1);
2121

2222
int Send(std::string message);
2323
int Send(const char *bytes, size_t byteslength);

easysocket/include/udpsocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class EASYSOCKET_API UDPSocket : public BaseSocket
1515
public:
1616
std::function<void(std::string, std::string, std::uint16_t)> onMessageReceived;
1717

18-
UDPSocket(FDR_ON_ERROR, int socketId = -1);
18+
explicit UDPSocket(FDR_ON_ERROR, int socketId = -1);
1919

2020
void SendTo(std::string message, std::string ipv4, uint16_t port, FDR_ON_ERROR);
2121
void SendTo(const char *bytes, size_t byteslength, std::string ipv4, uint16_t port, FDR_ON_ERROR);

0 commit comments

Comments
 (0)