operator= on fd_set - socket communication linux
I'm writing a program that uses select(), given a to-read fd_set.
In the program, i'm saving two fd_sets: 1. fd_set named DB with all the fd's i can deal with. 2. fd_set named toSelect - which i send to the select() method, and handles later after the select() returns.Before calling to select(), i'm doing this:
toSelect = DB; In order to copy all the fd's in DB to the toSelect fd_set. Since my program isn't working so well (coming up with the message "Connection reset by peer"), there's probably something wrong with my code. Is this assignment i开发者_Python百科s ok? If not, how can i copy one fd_set to another without using the operator= ? Thank you.Instead of doing toSelect = DB
, try using the FD_ISSET and FD_SET macros to copy the values from one to the other, and see if the problem persists.
The internal details of fd_set including whether or not operator= will be defined (and pass compilation) is implementation defined. The only things fd_set promises you is the interface it provides in the form of the macros (or functions) FD_SET, FD_CLEAR, FD_ISSET, FD_ZERO.
If you want to be able to use operator= you can write your own wrapper class for it.
精彩评论