check if the channel is a socket channel or serverSocketChannel before cast.

# Fixes classCastException crash
# The reactor shuts down in case of an exception on the serverSocketChannel