C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 07-30-2005, 10:42 AM   #1
Registered User
 
Join Date: Dec 2004
Location: The Netherlands
Posts: 89
socks4 server

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.
apsync is offline   Reply With Quote
Old 07-30-2005, 11:23 AM   #2
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,700
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.

Salem is offline   Reply With Quote
Old 07-30-2005, 01:59 PM   #3
Registered User
 
Join Date: Dec 2004
Location: The Netherlands
Posts: 89
oh, and and how should i initialise it

Last edited by apsync; 07-30-2005 at 02:03 PM.
apsync is offline   Reply With Quote
Old 07-30-2005, 02:08 PM   #4
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,700
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.

Salem is offline   Reply With Quote
Old 07-30-2005, 02:12 PM   #5
Registered User
 
Join Date: Dec 2004
Location: The Netherlands
Posts: 89
allright, thanks for replying, i did the following now;
Code:
DWORD WINAPI Socks4ClientThread(LPVOID pParam)
and
Code:
SOCKET client=(SOCKET)pParam;
but how should I call the function now,
Code:
Socks4ClientThread("something"); // I dunno what i have to fill here
apsync is offline   Reply With Quote
Old 07-30-2005, 02:16 PM   #6
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,700
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.

Salem is offline   Reply With Quote
Old 07-30-2005, 02:45 PM   #7
Registered User
 
Join Date: Dec 2004
Location: The Netherlands
Posts: 89
thanks everything looks fine now, but for some reason it hangs at this line

Code:
if (connect(outbound, (SOCKADDR *)&target_in, sizeof(target_in)) == SOCKET_ERROR)
any ideas what it can be?
Attached Files
File Type: c socks4.c (3.3 KB, 41 views)
apsync is offline   Reply With Quote
Old 07-30-2005, 07:27 PM   #8
Registered User
 
Join Date: Apr 2005
Posts: 134
Quote:
Originally Posted by apsync
thanks everything looks fine now, but for some reason it hangs at this line

Code:
if (connect(outbound, (SOCKADDR *)&target_in, sizeof(target_in)) == SOCKET_ERROR)
any ideas what it can be?
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()

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;
}
nkhambal is offline   Reply With Quote
Old 07-31-2005, 01:52 AM   #9
Registered User
 
Join Date: Dec 2004
Location: The Netherlands
Posts: 89
ah I see, thanks, now I can continue!
apsync is offline   Reply With Quote
Old 07-31-2005, 04:53 AM   #10
Registered User
 
Join Date: Dec 2004
Location: The Netherlands
Posts: 89
hmm not working, what can I do to receive the SYN-ACK packet from server
apsync is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
server client application - (i really need your help) sarahnetworking C Programming 3 03-01-2008 10:54 PM
Server Architecture coder8137 Networking/Device Communication 2 01-29-2008 11:21 PM
Where's the EPIPE signal? marc.andrysco Networking/Device Communication 0 12-23-2006 08:04 PM
IE 6 status bar DavidP Tech Board 15 10-23-2002 05:31 PM
socket question Unregistered C Programming 3 07-19-2002 01:54 PM


All times are GMT -6. The time now is 07:36 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22