Sunday, September 4, 2011

Using FD_ZERO Macro

select FD_ZERO


This C macro is used to initialize a file descriptor set. Before you can register file descriptors (which includes sockets), you must initialize your set to all zero bits. To initialize a file descriptor set named read_socks and write_socks, you would write the following C language statements:

Example

fd_set read_socks;
fd_set write_socks;
FD_ZERO(&read_socks);
FD_ZERO(&write_socks);

The first two statements declare the storage associated with the file descriptor sets. The last two statements, which use the FD_ZERO macro, initialize these sets to the empty set. In other words, after FD_ZERO has been applied on a set, there are no file  descriptors left registered within the set.

2 comments:

  1. Does your site have a contact page? I'm having problems locating it but, I'd like to shoot
    you an email. I've got some ideas for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it develop over time.
    My site ; Macro-Patterning Method

    ReplyDelete