CyberPsychotic wrote:
> > > I wonder how should this be done?
> >
> > With close().
>
> maybe there's a way to play with setsockopt or something? however so far I
> looked through Richard Steven's book, I haven't found anything.
No. You can only call connect() on a socket once.
> > > but isn't it an overkill?
> >
> > No. Unless you don't actually need to keep connecting and
> > disconnecting that is.
>
> ok. thanks. so close(sockfd) is equal to disconnecting it, right?
Right.
> > > it every time) or it's save enough to do it once. (so far I haven't noted
> > > connect does any mess with it, but... )
> >
> > connect() shouldn't modify the `struct sockaddr'.
> >
> > The prototype should have used `const struct sockaddr *', except that
> > the `const' keyword didn't exist when the sockets API was developed.
>
> hmm.. but I guess latter posix standard had it. right?
Had what? The sockets API or the `const' keyword?
The sockets API isn't part of the original Posix standard. The Unix
API retains compatibility with K&R C, which doesn't have a `const'
keyword.
I notice that glibc-2's sys/socket.h defines the argument as
`__CONST_SOCKADDR_ARG', which expands to `__const struct sockaddr *',
and `__const' expands to `const' when using ANSI C or C++, and empty
otherwise.
--
Glynn Clements <[EMAIL PROTECTED]>