If I understand you correctly, why can't you just close() or shutdown() the file descriptor? This will cause the peer to see a broken pipe (assuming you are using TCP sockets). You will need to set
the SO_KEEPALIVE (IIRC) socket option (man setsockopt) so the peer sees the disconnect immediately, otherwise the peer won't see it until the peer attempts to send.