|
@@ -22,12 +22,12 @@ bool CSocket::connect(const String& hostname, int port)
|
|
|
{
|
|
|
auto* hostent = gethostbyname(hostname.characters());
|
|
|
if (!hostent) {
|
|
|
- dbgprintf("CSocket::connect: Unable to resolve '%s'\n", hostname.characters());
|
|
|
+ dbg() << "CSocket::connect: Unable to resolve '" << hostname << "'";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
IPv4Address host_address((const u8*)hostent->h_addr_list[0]);
|
|
|
- dbgprintf("CSocket::connect: Resolved '%s' to %s\n", hostname.characters(), host_address.to_string().characters());
|
|
|
+ dbg() << "CSocket::connect: Resolved '" << hostname << "' to " << host_address;
|
|
|
return connect(host_address, port);
|
|
|
}
|
|
|
|
|
@@ -35,7 +35,7 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
|
|
{
|
|
|
ASSERT(!is_connected());
|
|
|
ASSERT(address.type() == CSocketAddress::Type::IPv4);
|
|
|
- dbgprintf("Connecting to %s...", address.to_string().characters());
|
|
|
+ dbg() << *this << " connecting to " << address << "...";
|
|
|
|
|
|
ASSERT(port > 0 && port <= 65535);
|
|
|
|
|
@@ -53,10 +53,10 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
|
|
int rc = ::connect(fd(), (struct sockaddr*)&addr, sizeof(addr));
|
|
|
if (rc < 0) {
|
|
|
if (errno == EINPROGRESS) {
|
|
|
- dbgprintf("in progress.\n");
|
|
|
+ dbg() << *this << " connection in progress (EINPROGRESS)";
|
|
|
m_notifier = make<CNotifier>(fd(), CNotifier::Event::Write);
|
|
|
m_notifier->on_ready_to_write = [this] {
|
|
|
- dbgprintf("%s{%p} connected!\n", class_name(), this);
|
|
|
+ dbg() << *this << " connected!";
|
|
|
m_connected = true;
|
|
|
m_notifier->set_event_mask(CNotifier::Event::None);
|
|
|
if (on_connected)
|
|
@@ -67,7 +67,7 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
|
|
perror("connect");
|
|
|
exit(1);
|
|
|
}
|
|
|
- dbgprintf("ok!\n");
|
|
|
+ dbg() << *this << " connected ok!";
|
|
|
m_connected = true;
|
|
|
return true;
|
|
|
}
|
|
@@ -76,7 +76,7 @@ bool CSocket::connect(const CSocketAddress& address)
|
|
|
{
|
|
|
ASSERT(!is_connected());
|
|
|
ASSERT(address.type() == CSocketAddress::Type::Local);
|
|
|
- dbgprintf("Connecting to %s...", address.to_string().characters());
|
|
|
+ dbg() << *this << " connecting to " << address << "...";
|
|
|
|
|
|
sockaddr_un saddr;
|
|
|
saddr.sun_family = AF_LOCAL;
|
|
@@ -96,7 +96,7 @@ ByteBuffer CSocket::receive(int max_size)
|
|
|
{
|
|
|
auto buffer = read(max_size);
|
|
|
if (eof()) {
|
|
|
- dbgprintf("CSocket{%p}: Connection appears to have closed in receive().\n", this);
|
|
|
+ dbg() << *this << " connection appears to have closed in receive().";
|
|
|
m_connected = false;
|
|
|
}
|
|
|
return buffer;
|