I found a code which should work, but it doesn't for me on Visual Studio 2017. It returns me "Error" (return(-1);) and some weird symbol after. Maybe for somebody else this code worked? https://gist.github.com/anhldbk/f62f...6959e3e0907c81
Printable View
I found a code which should work, but it doesn't for me on Visual Studio 2017. It returns me "Error" (return(-1);) and some weird symbol after. Maybe for somebody else this code worked? https://gist.github.com/anhldbk/f62f...6959e3e0907c81
I suspect your issue is here:
You can verify this by changing the error message here. If this is the issue, then you are not receiving the expected data.Code:char Resp2[10];
recv(Socket, Resp2, 10, 0);
if(Resp2[1] != 0x00)
{
std::cout << "[*] Error : " << Resp2[1] << std::endl;
return(-1); // ERROR
}
I know that issue is here, but how to fix it?
I see some problems in the code: https://imgur.com/a/t1L5B72
Well, for a start the code is not checking the return values from any function calls. For recv(), a bad return value is SOCKET_ERROR. If the return value is this, then call WSAGetLastError() to determine the error. See https://docs.microsoft.com/en-us/win...f-winsock-recv
When you call an API function, you should check the return value everytime. If this isn't an OK value, then you need to determine the error and deal with it. The documentation for each API states the return value, what is a good return and what possible errors could occur.
All the other API calls in the TOR code should also be checked as per their documentation.
PS Just because you found some code on githib, this does not mean that the code is well written - or even correct!
I'm getting https://imgur.com/a/2ftdaGy Do you know how to enable sdl warnings? Mine is enabled in C++/General/SDL checks. But it overrides anyway. As I remember I did something with command line to override SDL but I don't know how to revert it back. I'm getting warnings: Command line warning D9025: overriding '/sdl' with '/sdl-'
Error 10093 is WSANOTINITIALISED, which means WSAStartup() has not been called yet. See https://docs.microsoft.com/en-us/win...-error-codes-2
I don't see any reference to WSAStartup() in the github code? See https://docs.microsoft.com/en-us/win...ock-wsastartup
I did this: https://imgur.com/a/pQpa6pr from https://gist.github.com/anhldbk/f62f...6959e3e0907c81 and now I'm getting 10057
and if you look up that error code you get
From which API are you getting 10057? Are you now checking the return value from every API?Quote:
Socket is not connected.
A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied.
I suspect
is failing. What's the return value? If it's not 0, there is a problem here.Code:connect(Socket, (SOCKADDR*)&SocketAddr, sizeof(SOCKADDR_IN));
Return value is -1. I use console application. I get 10057 from console application.
Right, then you know the issue is with connect() and WSAGetLastError() will give you the reason for the error - as per post #5.
It looks like the code is using port 9050. Is this port enabled on your firewall?
VictorN WSAGetLastError(). 2kaud Is this problem has a solution?