Networking Forums

Networking Forums > Computer Networking > Linux Networking > socket read modifies third parameter after the call: Very strange

Reply
Thread Tools Display Modes

socket read modifies third parameter after the call: Very strange

 
 
jainarunk@gmail.com
Guest
Posts: n/a

 
      07-20-2006, 03:47 PM
Hello Group,

I am doing a socket read

char buf[2048];
int readLen = 2048;

cout<< "Readlen = " << readLen << endl; // Prints Readlen = 2048
read(sockfd, buf, readLen);
cout<< "Readlen = " << readLen << endl; // Prints Readlen = 28169

Can someone tell me what is going on. What went wrong. I am working
on Redhat Linux
platform.

Thx.

arun

 
Reply With Quote
 
 
 
 
Robert Harris
Guest
Posts: n/a

 
      07-20-2006, 09:15 PM
(E-Mail Removed) wrote:
> Hello Group,
>
> I am doing a socket read
>
> char buf[2048];
> int readLen = 2048;
>
> cout<< "Readlen = " << readLen << endl; // Prints Readlen = 2048
> read(sockfd, buf, readLen);
> cout<< "Readlen = " << readLen << endl; // Prints Readlen = 28169
>
> Can someone tell me what is going on. What went wrong. I am working
> on Redhat Linux
> platform.
>
> Thx.
>
> arun
>


1. Make sure you #include <unistd.h>
2. Check the return value of your read() and, if it is -1, print out the
value of errno.

Robert
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read all data from kernel buffer for a socket fd (which uses TCP ) will_u_tellmemore Linux Networking 0 12-21-2006 01:23 PM
socket call does not read full content jainarunk@gmail.com Linux Networking 6 07-22-2006 10:53 PM
ioctl() call with a raw socket??? john.chludzinski@gmail.com Linux Networking 0 03-28-2006 11:11 PM
NEED HELP Socket programming : HOW read and write with timeout TF Linux Networking 2 10-13-2005 02:12 PM
simultaneous read & write on socket fd Dirk Petera Linux Networking 0 09-15-2003 12:52 PM



1 2 3 4 5 6 7 8 9 10 11