Thread: recv()

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    13

    recv()

    I am writing client program, using sockets. The client also has to accept responses.

    I connect to the server ok, can send requests ok. The problem is when I try to recv().

    The main program deals with the send()ing stuff, I have fork()ed a new process to sit and recv() responses from the server.

    The program breaks after it has recieved one responce. I am using the same file descriptor for both send() and recv(), could this be the problem?

    The error message is:
    recv: Connection reset by peer

    Any help would be appreciated,
    Cheers

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Most of us aren't telepathic (not sure about Prelude and Salem), so it would help if you showed some code.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Based on the information you've provided, it appears the server is disconnecting from you after sending the response (much like an HTTP server).
    Jason Deckard

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    @afisher: Are we talking about a web server here?

    Assuming we are...

    >>The program breaks after it has recieved one responce.
    What was the response? If it was a good response (eg a web page), then your connection is possibly being closed because you didn't set the http keep-alive header. If it was a bad response, or simply no data at all, then your request was probably bad in the first place.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. recv() returns 0 the second time
    By Overlord in forum Networking/Device Communication
    Replies: 7
    Last Post: 07-10-2009, 04:09 AM
  2. Question about recv
    By carrotcake1029 in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-26-2009, 02:10 PM
  3. recv() problem
    By Massive in forum C Programming
    Replies: 5
    Last Post: 06-26-2003, 04:58 AM
  4. non blocking recv
    By rohit in forum Linux Programming
    Replies: 4
    Last Post: 03-05-2002, 09:35 PM
  5. recv function (blocking)
    By aurumice in forum Linux Programming
    Replies: 0
    Last Post: 03-01-2002, 01:19 AM