Thread: how receive the large data using recv function in c++?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Of course. Unless the socket is set non-block, recv() is a blocking call. Your condition is while(iByteCount > 0), but as long as the client stays connected and there are no errors, that will never happen*. This loop will just read everything the client sends, then keep waiting for more.

    You need to process the data as you receive it. That could mean just checking each chunk for ! until you find it then breaking out of the loop.

    * On linux, 0 will only happen if the client has disconnected, ie, the socket is defunct.
    Last edited by MK27; 04-04-2012 at 07:33 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to receive data from serial port?
    By coolrox86 in forum C++ Programming
    Replies: 1
    Last Post: 04-23-2010, 03:04 PM
  2. How to Receive data from serial/USB port ?
    By sunit in forum C Programming
    Replies: 3
    Last Post: 06-19-2009, 12:16 PM
  3. recv large amounts of data
    By kpreston in forum Networking/Device Communication
    Replies: 19
    Last Post: 10-16-2008, 03:03 PM
  4. [Large file][Value too large for defined data type]
    By salsan in forum Linux Programming
    Replies: 11
    Last Post: 02-05-2008, 04:18 AM
  5. I want to avtivate modem to receive data
    By marquish in forum Networking/Device Communication
    Replies: 2
    Last Post: 07-21-2005, 12:01 AM

Tags for this Thread