void OnSend(IAsyncResult ar) { Socket socket = (ar.AsyncState as Socket); try { socket.EndSend(ar); } catch { // whatever happens we close the socket } finally { socket.Close(); } }