exert from code: (just the essencial)
my ideia is: each time there is a new connection on the socket a new file descriptor is created and added to the file set. that way if i get a message on the file descritpr used in listen or any of the ones created before i can read from it.
(sfd is a tcp sockect, after listen instruction)
select(maxfd+1, &fdset, NULL, NULL, NULL);
if((newfd=accept(sfd,(struct sockaddr*)&addrs,&addrlens))==-1) ....
if (newfd>maxfd) maxfd=newfd;
add newfd to descriptors array
for cycle testing array of descriptors
the problem is: when i get the 1st connection on sfd, newfd is created and i can read from it, and add it to the fdset. when it enters 2 loop, the (FD_ISSET(sfd,&fdset)) condition is true again, when i know there was no connections on sfd.
am understanding this wrong, of do i have to flush, or clean, or something like that, sfd, so that select doesn´t think there is a new connection on it?