client-server programming
Stelios Bounanos
sb at dial.pipex.com
Thu Mar 22 20:05:02 EET 2001
In message <81FBBA8C21B9D311A6E500508B6144AA11DBEB at eupalinos.aegean.gr>,
Gousios Georgios <cs98011 at icsd.aegean.gr> wrote:
> Geia sas
> Ayth thn epoxh asxoloymai, logo panephsthmiou, me client server programming.
> Exv tis parakato apories:
>
> a)Mhpos yparxei kapia synarthsh san thn fflush pou na katharizei oti exei
> "perisepsei" se ena socket meta apo read?
Ftiakse mia poy na kanei non-blocking reads kai meta na epistrefei (des b))
> b)Yparxei tropos na kanoyme thn read na mhn "kollaei" se kapoio socket otan
> den briskei dedomena?
Nai, setareis to O_NONBLOCK me thn fcntl:
#include <unistd.h>
#include <fcntl.h>
#include ...
int sockfd, sockflags;
...
sockflags=fcntl(sockfd, F_GETFL, 0);
if ( sockflags < 0 )
handle_error_func("fcntl GETFL error");
sockflags |= O_NONBLOCK;
if ( fcntl(sockfd, F_SETFL, sockflags) < 0 )
handle_error_func("fcntl SETFL error");
Twra h read() 8a epistrefei -1 kai 8a to errno 8a ginetai EAGAIN
('h EWOULDBLOCK se orismena systhmata) an den yparxei tipota gia
diabasma.
> c)Oi signal handlers (px signal(SIGCHLD,func)) prepei na kaloyntai synexos
> se ena brogxo gia na doylepsoyn h apla ftanei na kleithoyn mia fora sthn
> arxh kai tha pianoyn ta signals otan ayta emfanistoyn?
>
Uhm, eksartatai apo to systhma soy, opote des ta manpages.
An exei thn sigaction(2), tote xrhsimopoihse aythn anti gia th signal
kai de 8a xreiazetai na ksanasetareis ton handler ka8e fora.
> Kathe boithia kalodexoymenh
> George
>
Rgds,
/-sb.
--
Stelios Bounanos <sb at dial.pipex.com>
..............7500000 years later:
The Ultimate Answer is 42.
(next mail will give the Question)
More information about the Linux-greek-users
mailing list