tcp_acceptor_impl.cpp 519 B

12345678910111213141516171819202122232425
  1. #include "tcp_acceptor_impl.h"
  2. using namespace NAsio;
  3. bool TOperationAccept::Execute(int errorCode) {
  4. if (errorCode) {
  5. H_(errorCode, *this);
  6. return true;
  7. }
  8. struct sockaddr_storage addr;
  9. socklen_t sz = sizeof(addr);
  10. SOCKET res = ::accept(Fd(), (sockaddr*)&addr, &sz);
  11. if (res == INVALID_SOCKET) {
  12. H_(LastSystemError(), *this);
  13. } else {
  14. NS_.Assign(res, TEndpoint(new NAddr::TOpaqueAddr((sockaddr*)&addr)));
  15. H_(0, *this);
  16. }
  17. return true;
  18. }