[LCP]sockets problem

Srinath © redindian at nettaxi.com
Thu Jan 31 01:41:31 UTC 2002


Hello all,
The program now works fine. Thanks for all your emails .
I have some more doubts. Thanks for spending your time in this.


> > #define CLIENTPORT 4999
> It's rather unusual to define the local port number.  You normally allow
>the  local port to be allocated automatically (though it won't hurt to do
this).

In my program, the client also listens for connections. so when i bind a
'listen' socket in client to some port (that is not known to server), then
how
will the server know which port to connect to in the client. In other words,
how do i do this - the server wants to send a  message to the client. how
does it fill the  : clientsockaddr_in.sin_port ?


> OK, here's your first big problem.  You're setting up "clientset" outside
>of your loop.  That only works the first time through.  After select()
returns,
>clientset  has one of the file descriptors set (which you correctly check
with
> FD_ISSET) but  it *stays* set the next time through the loop.  That means
that clientset
> is not set correctly the next time you call select().

i referred the man pages and it is not clear ; according to my 'wrong
source' what will happen :
1) the set file descriptor in the clientset will always remain set (or)
2) the set file descriptor in the clientset will be the only one tested
after that ??


>     if(FD_ISSET(0,&masterset))
>     {
>      /* CONTROL IS NEVER COMING HERE AS NOTHING IS PRINTED */
>       printf("keyboard getting ctrl");
>
> Actually, control *is* being passed here, but nothing gets printed until
>he  buffer for stdout gets flushed.  :-)  When I got this working the
program
>an  fine, and when I exited I had a line full of "keyboard getting ctrl"
>lushed to  stdout.

should i fflush(stdout) anywhere here?


Srinath





More information about the linuxCprogramming mailing list