일단 서버구현 끝
This commit is contained in:
26
impl/Socket/TCPSocket.cpp
Normal file
26
impl/Socket/TCPSocket.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "Socket/TCPSocket.hpp"
|
||||
#include "Socket/Log.hpp"
|
||||
#include "precomp.hpp"
|
||||
|
||||
namespace Chattr {
|
||||
|
||||
void TCPSocket::init(int domain) {
|
||||
sock_ = ::socket(domain, SOCK_STREAM, 0);
|
||||
if (sock_ == INVALID_SOCKET)
|
||||
log::critical("socket()");
|
||||
|
||||
valid_ = true;
|
||||
}
|
||||
|
||||
void TCPSocket::listen(int __n) {
|
||||
int retVal = ::listen(sock_, __n);
|
||||
if (retVal == INVALID_SOCKET)
|
||||
log::critical("listen()");
|
||||
}
|
||||
|
||||
void TCPSocket::accept(TCPSocket& newSock, Address& __addr) {
|
||||
newSock.move(::accept(sock_, &__addr.sockaddr, &__addr.length));
|
||||
if (newSock == INVALID_SOCKET)
|
||||
log::critical("accept()");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user