On Tue, 2009-09-29 at 16:08 +0200, Oscar F wrote:
> sorry kieran, sorry for my english, but i don´t understand
OK, you have this:
FD_ZERO(&acceptset);
maxfd=0;
for(i=0;i<NUM_SOCKET;i++)
{
FD_SET(lSocket[i], &acceptset);
if (lSocket[i]> maxfd)
maxfd = lSocket[i];
}
while(1){
ret = select(maxfd+1, &acceptset, NULL, NULL, NULL);
...
}
You need this instead:
while (1) {
FD_ZERO(&acceptset);
maxfd=0;
for(i=0;i<NUM_SOCKET;i++)
{
FD_SET(lSocket[i], &acceptset);
if (lSocket[i]> maxfd)
maxfd = lSocket[i];
}
ret = select(maxfd+1, &acceptset, NULL, NULL, NULL);
...
}
because acceptset is modified by the call to select, so you need to
reset it each time you call select, so you need that code in the loop.
> Can i connect in the same task(one thread) with different TCP sockets
> with different port ?
> socket 1 port 1500H
> socket 2 port 1501H
Yes.