On Mon, 2003-02-10 at 18:03, Dorin Lazar wrote:
> On Monday 10 February 2003 17:52, Florin Malita wrote:
> > Apeluri blocante la trimiterea datelor catre consumator presupun, nu
> > vad de ce nu ar putea face blocking read de pe socket.
>   Imposibilitatea de a realiza faptul ca a expirat o perioada te timp 
> (folosirea lui SIGALRM e exclusa, scriu o biblioteca).

TIP: Se poate face blocking read cu timeout - bagi un select inainte de
read:

ssize_t read_tout(int fd, void *buf, size_t count, int tout_sec){
        fd_set rd_set;
        struct timeval tv;
        int res;

        FD_ZERO(&rd_set);
        FD_SET(fd, &rd_set);

        tv.tv_sec = tout_sec;
        tv.tv_usec = 0;

        /* blocking cel mult tout_sec */
        if((res = select(fd + 1, &rd_set, NULL, NULL, &tv)) <= 0){
                /* error or timeout */
                return res;
        }

        /* acum read nu mai e blocking */
        return read(sock, buf, count);
}


spor

-- 
Florin Malita      web:        http://www.malinux.net
                   public key: http://www.malinux.net/data/fmalita.gpg

-- Attached file included as plaintext by Listar --
-- File: signature.asc
-- Desc: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQA+R9q09npXhj/Ohf8RAkvqAJ4mOIy8IFP0mQxiFcxwTxmNBjccbwCgnQk2
Vlk0sBGAhfJSDSTr5HtvTOU=
=jSo/
-----END PGP SIGNATURE-----


--
Pentru dezabonare, trimiteti mail la 
[EMAIL PROTECTED] cu subiectul 'unsubscribe rlug'.
REGULI, arhive si alte informatii: http://www.lug.ro/mlist/


Raspunde prin e-mail lui