Add more events, as one more is consumed by bsd socket layer.
Don't overwrite gpio configuration, just change led pins.
Use closesocket to close, otherwise socket fd is not released.