// socket layer will do the DNS resolve.
if (remote_address.ip_address.address().empty()) {
DCHECK(!remote_address.hostname.empty());
- dest_host_port_pair = net::HostPortPair::FromString(
- remote_address.hostname);
+ dest_host_port_pair = net::HostPortPair(remote_address.hostname,
+ remote_address.ip_address.port());
} else {
dest_host_port_pair = net::HostPortPair::FromIPEndPoint(
remote_address.ip_address);
<< kSendSocketBufferSize;
}
- DoSendSocketCreateMsg();
+ if (!DoSendSocketCreateMsg())
+ return;
+
+ DCHECK_EQ(state_, STATE_OPEN);
DoRead();
}
-void P2PSocketHostTcpBase::DoSendSocketCreateMsg() {
+bool P2PSocketHostTcpBase::DoSendSocketCreateMsg() {
DCHECK(socket_.get());
net::IPEndPoint local_address;
LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get local"
<< " address: " << result;
OnError();
- return;
+ return false;
}
VLOG(1) << "Local address: " << local_address.ToString();
LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get peer"
<< " address: " << result;
OnError();
- return;
+ return false;
}
VLOG(1) << "Remote address: " << remote_address.ToString();
if (remote_address_.ip_address.address().empty()) {
// packets sent before that by the application.
message_sender_->Send(new P2PMsg_OnSocketCreated(
id_, local_address, remote_address));
+ return true;
}
void P2PSocketHostTcpBase::DoRead() {