Re: Help regarding MSG_PEEK
- From: "Nils O. Selåsdal" <NOS@xxxxxxx>
- Date: Wed, 16 Aug 2006 15:46:52 +0200
Sunil Varma wrote:
Hi,You should not. Rather read what's thrown at you, and report
Is there any way to find the number of bytes filled in the socket
buffer maintained by the kernel.
For suppose if a UDP server application is receiving data on some
port.
How do I know the number of bytes filled in the buffer after it
has received some data without using any recv() or recvfrom() calls.
I have to know the number of bytes in the socket buffer based on
the socket number.
how much you've read. This is in most cases much more useful
that reporting what's received but not yet read by the application.
I requirement is, an appliction gives chance to open any number of
sockets(server/client).
The user can send, receive and see the statistics of the socket.
The statistics should display the total number of bytes of data
received at that point in time.
When I tried to do it with recvfrom() with MSG_PEEK, it always
shows the first received data.
calling recvfrom/recv with the MSG_PEEK flag tells you how big the next
packet to read is going to be. Then you read it (that is call recv/recvfrom without the MSG_PEEK flag.
Doing this for each packet isn't going to be very efficient. Provide
a buffer that can hold an entier udp packet, or decide on a max
packet size by other means.
.
- Follow-Ups:
- Re: Help regarding MSG_PEEK
- From: David Schwartz
- Re: Help regarding MSG_PEEK
- References:
- Help regarding MSG_PEEK
- From: Sunil Varma
- Help regarding MSG_PEEK
- Prev by Date: Re: "du -ks" but only for a user
- Next by Date: Use RPC?
- Previous by thread: Help regarding MSG_PEEK
- Next by thread: Re: Help regarding MSG_PEEK
- Index(es):
Relevant Pages
|