MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / IsConnected

Method IsConnected

src/util/sock.cpp:380–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380bool Sock::IsConnected(std::string& errmsg) const
381{
382 if (m_socket == INVALID_SOCKET) {
383 errmsg = "not connected";
384 return false;
385 }
386
387 char c;
388 switch (Recv(&c, sizeof(c), MSG_PEEK)) {
389 case -1: {
390 const int err = WSAGetLastError();
391 if (IOErrorIsPermanent(err)) {
392 errmsg = NetworkErrorString(err);
393 return false;
394 }
395 return true;
396 }
397 case 0:
398 errmsg = "closed";
399 return false;
400 default:
401 return true;
402 }
403}
404
405void Sock::Close()
406{

Callers 3

CheckControlSockMethod · 0.45
SanityCheckMethod · 0.45

Calls 2

IOErrorIsPermanentFunction · 0.85
NetworkErrorStringFunction · 0.85

Tested by

no test coverage detected