recv syscall for socket programming


 
Thread Tools Search this Thread
Top Forums Programming recv syscall for socket programming
# 1  
Old 04-01-2004
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 following order, taking a long time (couple of secs) to process each message received:

recv "Packet1"
-take 2 secs to process "Packet1"
recv "Packet2Packet3"


What throws me off is the second recv call that the server gets after processing the first recv call. The message is the contents of BOTH the packet 2 and packet 3 that the cilent sends.

It seems that recv reads whatever that is in the buffer, and not the sequence that message comes in. Is that true?

What I am planning to have is a server behaivor that is like this:

recv "Packet1"
- 2 sec of processing time
recv "Packet2"
- 2 sec of processing time
recv "Packet3"
- 2 sec of processing time


For example, since 3 messages are sent to the server, the server will have to call 3 recv explicity to get each individual message even though they are all already in the input buffer. Is that possible with recv?

Thanks
# 2  
Old 04-01-2004
Thanks, that make sense Smilie
# 3  
Old 06-16-2008
Thanks, that make sense

hi,

i'm facing the same problem too,
i know the reason, but struggling to solve it.

i found there is a socket type which will recv, packets exactly in the same order sent, without reading the whole junk from buffer...

if u know a way, kindly post....

Thnx,
sri
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Download file with socket syscall

Hello to all I want download a file in osx intel 64 with NASM , I want to use socket syscall This is part of my code section .data command db "GET /test/2.gif HTTP/1.1\r\nHost: 10.1.1.187\r\n\r\n", 0 ; url db "http://172.16.207.153/test/2.gif", 0 global main... (1 Reply)
Discussion started by: recher.jack
1 Replies

2. UNIX for Advanced & Expert Users

Socket programming

my socket program is not working with larger port numbers like more than 60000 , any reason why ? (4 Replies)
Discussion started by: Gopi Krishna P
4 Replies

3. Programming

Socket programming in C

Hi, I wanted to write a socket program in C, where I always want my socket connected to the server. i.e i shouldn't get disconnected once i get the response back from the server. I want to work in the connected mode, instead of disconnect and connect. Can somebody please kindly provide me a... (3 Replies)
Discussion started by: sudharma
3 Replies

4. IP Networking

socket programming

Hello Everyone Iam working on tcp/ip programming.with some time interval server has to send data.client has to close the connection and to open the connection between the time interval.this is the scenario when iam closing the connection in client side the connection terminates.how to... (1 Reply)
Discussion started by: sureshvaikuntam
1 Replies

5. 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

6. Programming

UDP socket - can both client and server recv and send

Hi, Am very new to socket programming. When we use UDP sockets to communicate between two processess, will both the client/server socket be able to send/recv ? meaning can sendto()/ recvfrom() be used on both server and client? It could be useful even if anybody provide some link on socket... (1 Reply)
Discussion started by: rvan
1 Replies

7. Programming

Socket Programming

Hi , I'm facing the following problem in socket programming. My structure is struct { int i; char *str; }samp; I'm creating the pointer to this structure and assigning the value to the structure members and send via the socket to the another process. The receiver process when... (7 Replies)
Discussion started by: arunviswanath
7 Replies

8. IP Networking

socket programming

my system is a stand alone system... i want to try doing socket porgramming..ihave heard that this is usually done during testing... how can i do that....? (6 Replies)
Discussion started by: damn_bkb
6 Replies

9. Programming

Socket Programming socket

Hello, I actually try to make client-server program. I'm using SCO OpenServer Release 5.0.0 and when I try to compile my code (by TELNET) I've got this error : I'm just using this simple code : and I get the same error if I use : If someone can help me, Thanks (2 Replies)
Discussion started by: soshell
2 Replies

10. IP Networking

TCP Programming problems with 'recv'

Hey, I am learning to program a TCP server and managed to get it up and running (I am using Windows 98SE). I can use the send function to send information to the client and I can use the recv function to ask the user to pass information through, but when I do so it only allows the client to... (1 Reply)
Discussion started by: KrazyGuyPaul
1 Replies
Login or Register to Ask a Question