
Write a TCP chat relay that listens on 127.0.0.1, accepts many clients at once, and forwards every message it receives to all the other connected clients. A single thread must stay responsive at all times, so the program is built around one I/O multiplexing loop and never blocks on a slow peer.
peer 0 connects, then peer 1 connectsrelay: peer 1 joinedpeer 0 sends "lgtm merge it\n"peer 0 says: lgtm merge itpeer 0 sends "who broke main" then later "?\n"peer 0 says: who broke main?chat_relay.csocketbindlistenacceptselectpollsignalsendrecvreadwriteclosesetsockoptfcntlhtonshtonlmalloccallocreallocfreememsetmemcpymemmovestrlenstrcpyatoisprintfsnprintfexit
Run the tests to grade your code
Write a TCP chat relay that listens on 127.0.0.1, accepts many clients at once, and forwards every message it receives to all the other connected clients. A single thread must stay responsive at all times, so the program is built around one I/O multiplexing loop and never blocks on a slow peer.
peer 0 connects, then peer 1 connectsrelay: peer 1 joinedpeer 0 sends "lgtm merge it\n"peer 0 says: lgtm merge itpeer 0 sends "who broke main" then later "?\n"peer 0 says: who broke main?chat_relay.csocketbindlistenacceptselectpollsignalsendrecvreadwriteclosesetsockoptfcntlhtonshtonlmalloccallocreallocfreememsetmemcpymemmovestrlenstrcpyatoisprintfsnprintfexit
Run the tests to grade your code