aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/neh/asio/tcp_acceptor_impl.cpp
blob: 7e1d75fcf57ac3c3a16c6b2fa547532a8c1ea546 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "tcp_acceptor_impl.h"

using namespace NAsio;

bool TOperationAccept::Execute(int errorCode) {
    if (errorCode) {
        H_(errorCode, *this);

        return true;
    }

    struct sockaddr_storage addr;
    socklen_t sz = sizeof(addr);

    SOCKET res = ::accept(Fd(), (sockaddr*)&addr, &sz);

    if (res == INVALID_SOCKET) {
        H_(LastSystemError(), *this);
    } else {
        NS_.Assign(res, TEndpoint(new NAddr::TOpaqueAddr((sockaddr*)&addr)));
        H_(0, *this);
    }

    return true;
}