Thread: winsock recv() function problem

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    12

    Angry winsock recv() function problem

    i have a problem in connecting to a pop server using winsock api.
    the situation is that my program connects to the server, recieves the responce of the server (that is a greeting message) but when i give further command (USER <username>, it does not retrieves data from the server.
    in fact the data (calculated number of bytes) are sent to the server but the recv function is blocked.
    ........i've tried by many aspects but same problem

    anybody who can help

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    I did a little pop thing a while back.....

    Are you allowing a big enough buffer to receive the "+ok" welcome.......

    After connect you should get something like ;

    "+ok welcome to sumedumnserver"

    I used to;

    Code:
    rcvcount = recv(s,welcome,strlen(welcome),0);
    	welcome[rcvcount] = '\0';
    Check it was ok and then discard the string.......

    Right after i did the "USER somedude"

    Have you checked the content of the welcome message?

    It used to work anyway

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    12

    Arrow check this out!!!

    in fact i've tried a different logic for doing the same thing.

    memset(buffer, 0, sizeof(buffer));
    recv(sock, buffer, sizeof(buffer), 0);

    these two lines serve the same purpose.

    can you send me the actual code or anyfurther help
    the problem is of real urgency
    thanks
    Last edited by Rizwan Rafique; 11-29-2001 at 06:42 PM.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    12

    Exclamation

    here is whole story attached as a file
    sorry for a lot of printf statements, they are jsut for quick debugging.

  5. #5
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    It seemed a little strange that the server could know when you've stopped sending your command without you telling it, and so I looked up the RFC and found that all commands must be ended with a CRLF pair.

    The call is blocking because the server doesn't know that's all of your command and hasn't sent a response, so there is nothing to receive.
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  6. #6
    Registered User
    Join Date
    Nov 2001
    Posts
    12

    thankyou buddy

    i really missed CRLF thing
    thankyou for reminding it to me

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Problem with function. Please help!
    By richdb in forum C Programming
    Replies: 9
    Last Post: 01-31-2006, 05:26 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Replies: 6
    Last Post: 03-02-2005, 02:45 AM
  5. Replies: 5
    Last Post: 02-08-2003, 07:42 PM