From 638a52dcfd02e55f1542f4369a04d9de39d31259 Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Tue, 27 Nov 2018 18:55:51 +0000 Subject: [PATCH] IDirectPlay8Peer: Debug messages when connecting to peers. --- src/DirectPlay8Peer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/DirectPlay8Peer.cpp b/src/DirectPlay8Peer.cpp index ce1d708..69861c6 100644 --- a/src/DirectPlay8Peer.cpp +++ b/src/DirectPlay8Peer.cpp @@ -435,6 +435,8 @@ HRESULT DirectPlay8Peer::Connect(CONST DPN_APPLICATION_DESC* CONST pdnAppDesc, I return DPNERR_INVALIDHOSTADDRESS; } + log_printf("hostname = '%S'", hostname_value); + if(host_sp == CLSID_DP8SP_TCPIP) { struct in_addr hostname_addr; @@ -475,6 +477,8 @@ HRESULT DirectPlay8Peer::Connect(CONST DPN_APPLICATION_DESC* CONST pdnAppDesc, I return DPNERR_INVALIDHOSTADDRESS; } + log_printf("port = %d", (int)(port_value)); + r_port = port_value; } else{ @@ -3317,6 +3321,8 @@ void DirectPlay8Peer::io_peer_connected(std::unique_lock &l, unsigne { /* TCP connection established. */ + log_printf("peer_id %u TCP connection established", peer_id); + if(peer->state == Peer::PS_CONNECTING_HOST) { PacketSerialiser connect_host(DPLITE_MSGID_CONNECT_HOST); @@ -3380,6 +3386,8 @@ void DirectPlay8Peer::io_peer_connected(std::unique_lock &l, unsigne else{ /* TCP connection failed. */ + log_printf("peer_id %u TCP connection failed: %s", peer_id, win_strerror(error).c_str()); + if(peer->state == Peer::PS_CONNECTING_HOST) { connect_fail(l, DPNERR_NOCONNECTION, NULL, 0); @@ -3840,6 +3848,11 @@ bool DirectPlay8Peer::peer_connect(Peer::PeerState initial_state, uint32_t remot r_addr.sin_addr.s_addr = remote_ip; r_addr.sin_port = htons(remote_port); + char s_ip[16]; + inet_ntop(AF_INET, &(r_addr.sin_addr), s_ip, sizeof(s_ip)); + + log_printf("Initiating connection to %s:%d as peer_id %u", s_ip, (int)(remote_port), peer_id); + if(connect(peer->sock, (struct sockaddr*)(&r_addr), sizeof(r_addr)) != -1 || WSAGetLastError() != WSAEWOULDBLOCK) { closesocket(peer->sock);