Re: Q about low lvl UNIX socket programming

From: animesh_singh@bbv.satyam.com
Date: Fri Apr 28 2000 - 07:20:39 EST


Thats simple for eg::
while(data_to_recv){
        // if ioctl returns -ve you are doomed
        if(ioctl(sock_descriptor,TIOCINQ,(unsigned long)&available) < 0){
                perror("ioctl");
                break;
        }
        if(available > data_to_recv)
                // this is last iteration but be careful
                bytes_recv = recvmsg(sock_descriptor,&buffer,data_to_recv,0);
        else
                //this should give all the data available in sock pipe
                bytes_recv = recvmsg(sock_descriptor,&buffer,available,0);
        
        data_to_recv = data_to_recv - bytes_recv;
}
with nonblocking sock recv will return immediatly with EAGAIGN if no data
is avaible so check for the presence of data in the sock pipe before
making any recv
Animesh

On Fri, 28 Apr 2000, Jerry Lundström wrote:

> On Fri, 28 Apr 2000 11:55:21 +0530 (IST), <animesh_singh@bbv.satyam.com> wrote:
>
> >On Thu, 27 Apr 2000, Jerry Lundström wrote:
> >
> >> Q: How can I check (using portable standards) how much is used in the
> >> buffers (send/recv) of a UNIX socket fd?
> >>
> > Use socket ioctl TIOCINQ to know how much data is avaible in the
> >sock buffer, take a look into the sunrpc/svcsock.c where NONBLOCKing mode
> >is used in conjuction with above ioctl
> >
>
> Thank you.
>
> Know any place where I can find information on what can be done with ioctl (the
> man page doesn't say a whole lot) ?
>
> --
> Jerry.Lundström:<jerry.lundstrom@citat.se>:system.developer/programmer
> icq.18682823:mobile+46.739.876053:phone+46.31.7107244:fax+46.31.7107201
> citat.solutions:Kronhusgatan.9:SE-411.05.Gothenburg:Sweden
> www.citat.se/solutions
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/
>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:15 EST