| 442 | } |
| 443 | |
| 444 | CSocket* CServerSocket::try_connect() |
| 445 | { |
| 446 | // Initialised? |
| 447 | if(m_fd <= 0) { |
| 448 | return nullptr; |
| 449 | } |
| 450 | |
| 451 | // Ignore further attempts until we're ready |
| 452 | if(m_clients.active() >= m_max_connections) { |
| 453 | return nullptr; |
| 454 | } |
| 455 | |
| 456 | struct sockaddr sa { |
| 457 | }; |
| 458 | host_socklen_t len = sizeof(sa); |
| 459 | int fd = ::accept(m_fd, &sa, &len); |
| 460 | if(fd < 0) { |
| 461 | return nullptr; |
| 462 | } |
| 463 | |
| 464 | if(socket_blocking(fd, false)) { |
| 465 | CSocket* skt = new_connection(fd, CSockAddr(sa)); |
| 466 | if(skt) { |
| 467 | m_clients.add(skt); |
| 468 | return skt; |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | socket_close(fd); |
| 473 | return nullptr; |
| 474 | } |
nothing calls this directly
no test coverage detected