| 1356 | } |
| 1357 | |
| 1358 | int Socket::CheckConnected(int sockfd) { |
| 1359 | if (sockfd == STREAM_FAKE_FD) { |
| 1360 | return 0; |
| 1361 | } |
| 1362 | int err = 0; |
| 1363 | socklen_t errlen = sizeof(err); |
| 1364 | if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &err, &errlen) < 0) { |
| 1365 | PLOG(ERROR) << "Fail to getsockopt of fd=" << sockfd; |
| 1366 | return -1; |
| 1367 | } |
| 1368 | if (err != 0) { |
| 1369 | CHECK_NE(err, EINPROGRESS); |
| 1370 | errno = err; |
| 1371 | return -1; |
| 1372 | } |
| 1373 | |
| 1374 | if (FLAGS_log_connected) { |
| 1375 | butil::EndPoint local_point; |
| 1376 | CHECK_EQ(0, butil::get_local_side(sockfd, &local_point)); |
| 1377 | LOG(INFO) << "Connected to " << remote_side() |
| 1378 | << " via fd=" << sockfd << " SocketId=" << id() |
| 1379 | << " local_side=" << local_point; |
| 1380 | } |
| 1381 | |
| 1382 | // Doing SSL handshake after TCP connected |
| 1383 | return SSLHandshake(sockfd, false); |
| 1384 | } |
| 1385 | |
| 1386 | int Socket::DoConnect(const timespec* abstime, |
| 1387 | int (*on_connect)(int, int, void*), void* data) { |
no test coverage detected