#CA4 cannot connect to peer

Hello, I am working with Qt so sorry if that brings other issues

But I am working through the stage to perform the handshake and cannot connect to the peer correctly, I am using a QTcpSocket and the same ip:socket as in the example from the previous step, I have tried all 3 peers but get the same result, I am not very familiar with TcpSockets and networking stuff so not entirely sure where the fault might be

also, when I set waitForConnected to 10000 I get “connection refused”

this is my debugging output:
Peer: “165.232.35.114” : 65523
Peer: “165.232.41.73” : 51288
Peer: “165.232.38.164” : 65513
Could not connect: "Socket operation timed out"

This is my code:

void Client::connectPeers(QList<QPair<QString, quint16>> peerList){
socket→connectToHost(peerList[0].first, peerList[0].second)
if(!socket→waitForConnected(5000)){
qWarning() <<“could not connect: “ << socket→errorString();}
}

Hey @GratG, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

sure I uploaded it here on my regular github if thats fine, its not 1:1 to the site challenge because I wanted to use Qt and expand it later (hope thats alright)

You should be able to build with cmake and run it like normal, just click file, add torrent on the top left to select the sample.torrent, the part I am working on atm is in the Client.cpp

Thanks! its pretty messy so sorry if its hard to understand haha, appreciate all the help either way

Sorry I am dumb :sob:

found my issue, I was getting the wrong socket values, don’t know how I missed that!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.