Re: How Can I call close() for all



sreyas.jose@xxxxxxxxx writes:

I have a server application that uses a communication loop
with a select to handle multiple clients.

How Can I call close() for all
the sockets currently open? (i.e., all the clients currently
connected) Will that cause any sort of trouble?

Not for the system. Whether it causes trouble for the clients depends
on the clients...

What I want/need to do is to implement a mechanism to
shutdown the server, so I'm wondering if I can just go
through the list of the sockets and close them (well,
maybe sending them a message first).

If all you want to do is make sure they're all closed, you can just
stop your server. All open file descriptors are closed while a
process is shutting down.

If you want to send a message first, you can just go through all the
file descriptors that have clients connected and send it. Presumably
you're keeping track of them.

.



Relevant Pages

  • sockets, closing and TIME_WAIT
    ... During heavy load the server can't follow anymore because the sockets ... my server should be able to handle 10 clients connecting ... This gets a free position in the array of connections, ...
    (comp.unix.programmer)
  • Re: blocking non blocking
    ... not connected to incoming data on the same thread, async sockets have to be ... somehow a server with 50K threads, ... or overlapped I/O servicing 50K clients. ... read and learnt about blocking and non blocking, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Moving files from clients to the server
    ... I'm not very familiar with sockets but I'll look into that, ... >> files should be passed to the server. ... the fastest way to create them is on the clients' machines. ... >> Another solution is to steam the files over the network. ...
    (microsoft.public.vc.atl)
  • Re: blocking non blocking
    ... Ok now i am very confused...here is why i think non blocking is less ... non blocking sockets typically involve some busy waiting and ... somehow a server with 50K threads, ... or overlapped I/O servicing 50K clients. ...
    (microsoft.public.win32.programmer.networks)
  • Re: (SAMBA) issue with filehandles being released under 6.1-RELEASE?
    ... it's related to Samba-3.0.22c and sockets / filehandles. ... My machine is a local / preferred master (smbd fights with XP Home ... clients because they want to be master browsers), ...
    (freebsd-questions)