Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

SocketSet - dup?

Moderators: larsivi kris

Posted: 11/17/08 05:11:25 Modified: 11/17/08 05:12:30

DISCLAIMER: This is most likely a noob question, and you're free to tell me I'm an idiot.
That said...
I'm working on a network application, and I've decided to abandon the approach to networking I used in Java (use threads to run all blocking calls), and go back to the C method (using select()) because it's so much safer. Or so I believe.
The problem is that I want to just have each Socket I make add itself to a static SocketSet?, which is fairly simple, but since running select() on a SocketSet? erases the sockets that have no data/connections, I can either have a SocketSet? that contains all Socket's and a SocketSet? that contains only the "active" sockets, or I can add every Socket to the SocketSet? every time I want to run select().
The first option is obviously better, but how could I duplicate the set of all sockets for use as the set of active sockets? I think I need to write a dup method, but how would I go about that? Is it as simple as running memcpy (or some equivalent), or does D have a better way?

Author Message

Posted: 11/17/08 09:14:44

If you want to use select, look up the package.

As for memcpy, that is typically how data is copied also in D, but feel to create a ticket where you request a SocketSet?.dup method.