Socket Programming Question

Discussion in 'C Programming' started by Shaun Duncan, Jul 29, 2006.

  1. Shaun Duncan

    Shaun Duncan Guest

    Ok, so I'm not good with sockets, but I need some help. Every now and then,
    when I call recv() to get the message sent by a client I wrote, it adds more
    characters to the buffer than was indicated by the return value of recv().
    Example, a particular call returns:

    (53 -- 62): GET /images/mspaint.bmp HTTP/1.0 HOST: localhost:4210host:4210
    (53 -- 62): GET /images/mspaint.bmp HTTP/1.0 HOST: localhost:4210host:4210
    (47 -- 52): GET /document.txt HTTP/1.0 HOST: localhost:4210:4210

    The first number is returned by recv() and the second is the value of
    strlen() of the buffer. I'm stumped....any suggestions?

    Thanks!
    Shaun Duncan, Jul 29, 2006
    #1
    1. Advertising

  2. Shaun Duncan

    Shaun Duncan Guest

    "Shaun Duncan" <> wrote in message
    news:eae8do$d9r$...
    > <snip>


    Looks like I figured it out...forgot to write '\0' to the end of the
    buffer...d'oh!
    Shaun Duncan, Jul 29, 2006
    #2
    1. Advertising

  3. "Shaun Duncan" <> writes:
    > "Shaun Duncan" <> wrote in message
    > news:eae8do$d9r$...
    >> <snip>

    >
    > Looks like I figured it out...forgot to write '\0' to the end of the
    > buffer...d'oh!


    Glad you solved it. In the future, be aware that standard C doesn't
    support sockets; try comp.unix.programmer.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Jul 29, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,761
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    945
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    526
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    644
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    699
Loading...

Share This Page