Open jwikiera opened 2 months ago
Oh well, it sometimes passes grademe on linux sometimes not. I had the chance to try on mac and select seems to behave differently, the solution of the repo works.
just by changing if (fd != except && FD_ISSET(fd, &write_set) && fd != serverfd) {
this if statement with the serverfd global check worked for me , thanks for the idea. Despite the int declared twice global int serverfd, and int serverfd in main, which I removed.
I also didn't add the select on the send_to_all and It passed the grademe, not sure about the actual exam. the current solution in this repo does not pass grademe for me but it does with this changes
create a pull request and I’ll update the code.
Hello, I have been compiling this repo's solution and variations of it, since some time, on various linuxes and compilers. Consistently, I get the situation where after a couple compiles and program starts, netcat disconnects as soon as I try to send a message with it. I heard (but can't find a source for it), that it's bad practice to pass in write ready descriptors to select if we actually don't want to write to them, especially in a loop. In my implementation, I add the current fds to write_set only at the beginning of the
send_to_all
function, before rerunning a select on them. At function exit, IFD_ZERO
the write set.Here is the full code which currently passes the grademe.fr test exam:
Code
```c #include