Linux TCP/IP programming part II
Giorgos Keramidas
keramida at ceid.upatras.gr
Sat Jun 24 19:20:33 EEST 2000
On Fri, Jun 23, 2000 at 10:21:51PM +0300, The Reverant wrote:
>
> fd_set rfds;
> struct timeval tv;
> int retval;
>
> conn=accept(sock, (struct sockaddr *) &address, &addrLength)
> FD_ZERO(&rfds);
> FD_SET(conn, &rfds);
>
> tv.tv_sec = 10;
> tv.tv_usec = 0;
> retval=select(1, &rfds, NULL, NULL, &tv);
> if(retval)
> cout << "Exoume data!\n";
> else
> {
> cout << "problem! den esteile o allos data mesa sta 10 secs. timeout!\n";
> close(conn);
> }
>
> To problima einai oti o,ti kai osa data na steilei o allos host, i select() den
> to katalabainei me tipota, les kai den stelnei tipota o allos. Etsi iparxei
> panta timeout meta apo 10 secs! Ti mporei na ftaei? Iparxei mipos allos tropos
> na ginei i douleia?
Diabase to manpage tis select(). Kai prosoxi sto TI einai to prwto
argument. Kai meta afou katalabeis giati einai lathos auto pou ekanes,
kane to ejhs:
fd_set rfds;
struct timeval tv;
int retval;
conn = accept(sock, (struct sockaddr *) &address, &addrLength)
FD_ZERO(&rfds);
FD_SET(conn, &rfds);
tv.tv_sec = 10;
tv.tv_usec = 0;
retval = select(conn + 1, &rfds, NULL, NULL, &tv);
if(retval) {
printf("data received in first 10 seconds\n");
} else {
printf("input timeout after 10 seconds\n");
close(conn);
}
Ah nai, kai otan breis xrono, paikse me to indent(1). Kanei kali
doulitsa otan esu bariesai na grafeis me sugkekrimeno style panta :)
--
Giorgos Keramidas, < keramida @ ceid . upatras . gr >
For my public key: finger keramida at ceid.upatras.gr
--
linux-greek-users mailing list -- http://lists.hellug.gr
More information about the Linux-greek-users
mailing list