hello i am trying to make a socks4 server for windows(xp) using ms-vc++6.
it works fine untill the recv() part,
there, it returns error code 10038 (WSAGetLastError),
can someone take a look at my code plz
hello i am trying to make a socks4 server for windows(xp) using ms-vc++6.
it works fine untill the recv() part,
there, it returns error code 10038 (WSAGetLastError),
can someone take a look at my code plz
Last edited by apsync; 07-30-2005 at 02:13 PM.
http://www.mailsbroadcast.com/email....rror.codes.htm
Considering that the client variable in Socks4ClientThread is uninitialised, I'm surprised it gets that far
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
oh, and and how should i initialise it
Last edited by apsync; 07-30-2005 at 02:03 PM.
I'd have said pass it as a parameter from one function to another.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
allright, thanks for replying, i did the following now;
andCode:DWORD WINAPI Socks4ClientThread(LPVOID pParam)
but how should I call the function now,Code:SOCKET client=(SOCKET)pParam;
Code:Socks4ClientThread("something"); // I dunno what i have to fill here
Since you're not actually using threads or anything (despite the names), and just calling functions directly, you may as well have
void Socks4ClientThread(SOCKET client); // prototype
Socks4ClientThread(client); // call
void Socks4ClientThread(SOCKET client) // definition
And lose the local variable of the same name in that function.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thanks everything looks fine now, but for some reason it hangs at this line
any ideas what it can be?Code:if (connect(outbound, (SOCKADDR *)&target_in, sizeof(target_in)) == SOCKET_ERROR)
It is not hanging. Probably the server to which you are trying to connect, is not running. connect() has sent the SYN and waiting for SYN-ACK from server. If it does not receive SYN-ACK from server till the SYN timout period, it will return with error. The timeout period is different on different platforms. Like on linux/bsd it is 72 secs usually. You can change the socket timeout using setsockopt()Originally Posted by apsync
Here is one way to do it
Code:void setsockettimeout() { struct timeval tv; tv.tv_sec = 30; /* timeout in 30 Secs */ setsockopt(sockid, SOL_SOCKET, SO_SNDTIMEO,(struct timeval *)&tv,sizeof(struct timeval)); setsockopt(sockid, SOL_SOCKET, SO_RCVTIMEO,(struct timeval *)&tv,sizeof(struct timeval)); return; }
ah I see, thanks, now I can continue!
hmm not working, what can I do to receive the SYN-ACK packet from server