![]() |
|
FD_ISSET Segmentation Fault?!! |
Daniel McKinnon
Member #1,463
August 2001
![]() |
Okay, this makes absolutely no sense to me: The line: a = FD_ISSET( net->sockfd, &net->fd ); where a is an integer, and net is of type networktype Why, Oh why would it ever segmentation fault THERE?! |
Steve Terry
Member #1,989
March 2002
![]() |
Why do you need to pass in the address of fd... it's not like anything is changed in ISSET. ___________________________________ |
Billybob
Member #3,136
January 2003
|
ST: Because that's the way it's delcared. As for the segmentation fault, maybe you need to ZERO the set before doing anything else to it?
|
Steve Terry
Member #1,989
March 2002
![]() |
Sorry I couldn't remember off the top of my head.. I should of researched. ___________________________________ |
Daniel McKinnon
Member #1,463
August 2001
![]() |
The set is FD_ZERO'ed, this is mind boggling... Edit: Actually, I should mention that I'm trying to use select() as a method of non-blocking sockets. Now, one of the funny things I encountered, is that it never seems to time out, and that the call to FD_SET is passing a 1 a whole bunch of times, but then suddenly (but consistantly) gives me a segmentation fault, I beleive (but I'm not sure) when select() finally times out. It's still mind boggling. |
Steve Terry
Member #1,989
March 2002
![]() |
Did you set timeval t to { 0, 0 }? ___________________________________ |
Daniel McKinnon
Member #1,463
August 2001
![]() |
notta, it's actually {2,50000}, but I don't think that would work anyways. I'm lead to beleive that I have some kind of strange memory leak or what-have-you, but I just can't seem to figure out where it is. It's okay, this code was second prototype anyhow. I'm on my second draft of engineering, and I was hoping to get at least something usefull out of it. I guess I did. Thanks for the help anyways. By the way, tip to all you NEWBIES out there, a good plan is to brainstorm, write two engineering drafts, a final engineering document, and make prototypes along the way. Once your done, write the documents and you should have a solid peice of code. (unlike this silly spaghetti masterpeice) |
aquasync
Member #3,964
October 2003
|
Yeah, a bit confusing, I had to figure this same stuff out to write a daemon recently. Anyway, your timeout problem is possibly the same mistake I made, which is that you need to re-set the timeout every time. Also check the fd values aren't greater than MAX_FD (or whatever the define is). |
ReyBrujo
Moderator
January 2001
![]() |
Are you sure you have cleared the set and set the descriptor correctly? -- |
Thomas Fjellstrom
Member #476
June 2000
![]() |
isnt fd supposed to be one more than the max fd you put in a set? -- |
Daniel McKinnon
Member #1,463
August 2001
![]() |
Never had a problem with the timeout, I was indeed always setting it. The descriptors were being set properly, I've done it a million times before. sockfd+1 was always under FD_MAX, but good observation. I scrapped that prototype anyhow, I'm onto my final draft here, and It's looking pretty darn solid so far. Thanks for the help anyways though. |
|