Sponsored Content
Full Discussion: regarding recv function
Special Forums IP Networking regarding recv function Post 302578180 by kavitha rao on Thursday 1st of December 2011 03:58:10 AM
Old 12-01-2011
Question regarding recv function

hi,

the syntax of recv function is:
Code:
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
 

10 More Discussions You Might Find Interesting

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

2. Forum Support Area for Unregistered Users & Account Problems

Forgotten Password and no email recv'd

I have forgotten my password and twice have entered my email address in your 'Forgotten Password' screen, but have received no email about how to proceed. Do you know what's wrong - please advise. Thanks. Jan (jvander) (0 Replies)
Discussion started by: jvandernopasswd
0 Replies

3. Programming

send and recv ARP package in AS3.0

In attachment, is the code to test IP by ARP proxy. I always use it to test a IP already existing in my cluster. Usage: arp_func eth0 192.168.1.1 Enviroment: IA64, RedHat AS3.0, 2.4.21-15.EL, gcc-3.2.3-34, "gcc -o arp_func arp_func.c" When the code below added before... (0 Replies)
Discussion started by: lameryang
0 Replies

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

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

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

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

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

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

10. Programming

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... (2 Replies)
Discussion started by: Errigour
2 Replies
recv(2) 							System Calls Manual							   recv(2)

Name
       recv, recvfrom, recvmsg - receive a message from a socket

Syntax
       #include <sys/types.h>
       #include <sys/socket.h>

       cc = recv(s, buf, len, flags)
       int cc, s;
       char *buf;
       int len, flags;

       cc = recvfrom(s, buf, len, flags, from, fromlen)
       int cc, s;
       char *buf;
       int len, flags;
       struct sockaddr *from;
       int *fromlen;

       cc = recvmsg(s, msg, flags)
       int cc, s;
       struct msghdr msg[];
       int flags;

Description
       The and system calls are used to receive messages from a socket.

       The call can be used only on a connected socket. The and calls can be used to receive data on a socket, whether or not it is in a connected
       state.  For further information, see

       If from is nonzero, the source address of the message is filled in.  The fromlen is a value-result parameter, initialized to  the  size	of
       the buffer associated with from, and modified on return to indicate the actual size of the address stored there.  The length of the message
       is returned in If a message is too long to fit in the supplied buffer, excess bytes can be discarded, depending on the type of  socket  the
       message is received from.  For further information, see

       If  no  messages  are  available  at  the socket, the receive call waits for a message to arrive, unless the socket is nonblocking.  If the
       socket is nonblocking, a of -1 is returned, and the external variable errno is set to EWOULDBLOCK.  For further information, see

       The call can be used to determine when more data arrives.

       The flags argument to a send call is formed by ORing one or more of the values following values:
       #define	 MSG_OOB   0x1	/* process out-of-band data */
       #define	 MSG_PEEK  0x2	/* peek at incoming message */
       The call uses a msghdr structure to minimize the number of directly supplied parameters.  This structure has the following form, as defined
       in <sys/socket.h>:
       struct msghdr {
	      caddr_t  msg_name;	/* optional address */
	      int      msg_namelen;	/* size of address */
	      struct   iov *msg_iov;	/* scatter/gather array */
	      int      msg_iovlen;	/* # elements in msg_iov */
	      caddr_t  msg_accrights;	/* access rights sent/received */
	      int      msg_accrightslen;
       };
       Here,  msg_name and msg_namelen specify the destination address if the socket is unconnected; msg_name can be given as a null pointer if no
       names are desired or required.  The msg_iov and msg_iovlen describe the scatter gather locations, as described in Access rights to be  sent
       along with the message are specified in msg_accrights , which has length msg_accrightslen .

Return Values
       These calls return the number of bytes received, or -1 if an error occurred.

Diagnostics
       The call fails under the following conditions:

       [EBADF]	      The argument s is an invalid descriptor.

       [EINVAL]       The argument length of the message is less than 0.

       [EMSGSIZE]     The message sent on the socket was larger than the internal message buffer.

       [ENOTCONN]     A call was made to from an unconnected stream socket.

       [ENOTSOCK]     The argument s is not a socket.

       [EWOULDBLOCK]  The socket is marked nonblocking and the receive operation would block.

       [EINTR]	      The receive was interrupted by delivery of a signal before any data was available for the receive.

       [EFAULT]       The  data  was  specified  to  be  received  into a nonexistent or protected part of the process address space. The argument
		      fromlen points outside the process address space.

See Also
       read(2), send(2), socket(2)

																	   recv(2)
All times are GMT -4. The time now is 10:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy