socks4 server

This is a discussion on socks4 server within the Networking/Device Communication forums, part of the General Programming Boards category; hello i am trying to make a socks4 server for windows(xp) using ms-vc++6. it works fine untill the recv() part, ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    91

    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.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,341
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    91
    oh, and and how should i initialise it
    Last edited by apsync; 07-30-2005 at 02:03 PM.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,341
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    91
    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

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,341
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    91
    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 Attached Files

  8. #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;
    }

  9. #9
    Registered User
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    91
    ah I see, thanks, now I can continue!

  10. #10
    Registered User
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    91
    hmm not working, what can I do to receive the SYN-ACK packet from server

Popular pages Recent additions subscribe to a feed

Similar Threads

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

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