Linux TCP/IP programming part II
The Reverant
reverant at freemail.gr
Fri Jun 23 22:21:51 EEST 2000
Paides xaireto kai efharisto osous edosan boitheia gia to proigoumeno erotima
mou. Telika afto pou doulepse itan to eksis aplo:
otan kaneis accept(int s, struct sockaddr *addr, int *addrlen) i
accept() simplironei tin addr me ta stoixeia tou host pou sindeetai. Tora omos
prokiptei allo zitima. Esto oti sindeetai kapoios host me int conn=accept()
k.t.l. Thelo an den stilei kati o allos host mesa se p.x. 10 defterolepta, na
ginetai disconnected. Gia afto xrisimopoio tin function select() (man 2
select) os eksis:
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?
Efharisto prokatabolika
Dimitris
--
linux-greek-users mailing list -- http://lists.hellug.gr
More information about the Linux-greek-users
mailing list