GIGA REFACTOR
This commit is contained in:
@@ -14,10 +14,10 @@ namespace network {
|
||||
TCPListener::TCPListener() {}
|
||||
|
||||
TCPListener::~TCPListener() {
|
||||
destroy();
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool TCPListener::listen(uint16_t port, int maxConnections) {
|
||||
bool TCPListener::Listen(uint16_t port, int maxConnections) {
|
||||
if ((m_Handle = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
|
||||
return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ bool TCPListener::listen(uint16_t port, int maxConnections) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TCPListener::accept(TCPSocket& newSocket) {
|
||||
bool TCPListener::Accept(TCPSocket& newSocket) {
|
||||
int addrlen = sizeof(newSocket.m_RemoteAddr);
|
||||
if ((newSocket.m_Handle = ::accept(m_Handle, reinterpret_cast<sockaddr*>(&newSocket.m_RemoteAddr),
|
||||
reinterpret_cast<socklen_t*>(&addrlen))) < 0)
|
||||
@@ -48,21 +48,21 @@ bool TCPListener::accept(TCPSocket& newSocket) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TCPListener::destroy() {
|
||||
void TCPListener::Destroy() {
|
||||
if (m_Handle < 0)
|
||||
::closesocket(m_Handle);
|
||||
}
|
||||
|
||||
bool TCPListener::close() {
|
||||
bool TCPListener::Close() {
|
||||
if (::shutdown(m_Handle, SD_BOTH) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TCPListener::setBlocking(bool blocking) {
|
||||
bool TCPListener::SetBlocking(bool blocking) {
|
||||
unsigned long mode = blocking ? 0 : 1;
|
||||
|
||||
if (ioctlsocket(m_Handle, FIONBIO, &mode) < 0) {
|
||||
if (::ioctlsocket(m_Handle, FIONBIO, &mode) < 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user