How can I tell when recv is finished with pending data?


 
Thread Tools Search this Thread
Top Forums Programming How can I tell when recv is finished with pending data?
# 1  
Old 05-04-2012
How can I tell when recv is finished with pending data?

I'm working with recv and I am having a heck of a lot of trouble ignoring excess data that I did not ask for. I was hoping someone could shine some light on the subject for me because I'm not getting anywhere fast.

---------- Post updated at 02:46 AM ---------- Previous update was at 12:31 AM ----------

Ok wow I was already given this answer I just didn't understand it. this is solved.
Sorry about this post.

---------- Post updated at 02:47 AM ---------- Previous update was at 02:46 AM ----------

When recv() is finished with a single send it null terminates with '\n'
# 2  
Old 05-04-2012
Read one character at a time into a larger buffer than you need.

Stop when you receive \n. That's when you know it's done.

Copy into the actual buffer, up to the the end of what you actually wanted. This ignores any you didn't need.
# 3  
Old 05-04-2012
Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. IP Networking

regarding recv function

hi, the syntax of recv function is: int recv( int sockfd, void *buffer, int length, unsigned int flags); Suppose i declared a buffer of size 100 ,then length to be specified in recv function is sizeof(buffer) or sizeof(buffer)-1 ( i.e 100 or 99) thanks in advance (2 Replies)
Discussion started by: kavitha rao
2 Replies

2. UNIX for Dummies Questions & Answers

pending signals

I was wondering about following. If I have set of 3 signals. And they are all blocked.Now at some point in the program the set is unblocked. Which signal will be delivered first.This is my set....SIGTSTP,SIGQUIT,SIGINT.When I added them in the set and unblock them I did it in following order... ... (1 Reply)
Discussion started by: joker40
1 Replies

3. Programming

Recv() call with timer(time out )

Hi all, I am facing a problem in recv() system call i.e.. in my project i have to implement timer for sending (data) and resending purpose when there is no acknowledgement. is there any way that recv() sys call has its own timer i.e., for ex: recv() has to wait for 10 secs. if any one knows... (2 Replies)
Discussion started by: Rohil
2 Replies

4. Programming

ABOUT RECV() SYSTEM CALL (regarding timer)

Hi all, I am facing a problem in recv() system call i.e.. in my project i have to implement timer for sending (data) and resending purpose when there is no acknowledgement. is there any way that recv() sys call has its own timer i.e., for ex: recv() has to wait for 10 secs. if any... (0 Replies)
Discussion started by: Rohil
0 Replies

5. Programming

recv syscall for socket programming

I have a question regarding the recv syscall. Suppose I have a client/server and the following exchange of message took place: Client --> Server using multiple send syscalls one after another immediately: send "Packet1" send "Packet2" send "Packet3" Server receives in the... (2 Replies)
Discussion started by: heljy
2 Replies

6. Programming

C Network Programming - recv() help

So I'm making a program that gets the IP Address of an inputed website, then sends the IP Address to an inputed host. This program has no real meaning, but just a learning experiment. So I sucessfully made the program, then I wanted to try out recv(), and it produces some weird output; here is the... (2 Replies)
Discussion started by: Octal
2 Replies

7. Programming

msgrcv pending forever !!!

When I am using msgrcv to get a message from a queue, in case of msgsnd some error, the msgrcv thread will waiting forever. Is there some way that I can specify a time out value for this queue ? just let msgrcv wait for some time, if no message comes during this time slot, msgrcv just return... (3 Replies)
Discussion started by: Yun Gang Chen
3 Replies

8. IP Networking

recv() not workin fine.....

hi ! In my program I have a structure as shown below: struct data { int a; char *b; long c; }str; i have assigned the following values to it: strcpy(str.b,"John"); str.a=10; str.c=123435; The client is tryin to send struct data to the server using send(sock,(char *... (2 Replies)
Discussion started by: mridula
2 Replies

9. Programming

recv() problems using AIX 4.33

I am opening a server socket on one of our machines and connection to it on the other machine. After making the connection if ether one of the systems does a recv() and ther is no data to receive then the buffer is filled with spaces and returns. I have no way of knowing if it is valid or not. ... (1 Reply)
Discussion started by: hazard0007
1 Replies
Login or Register to Ask a Question