improve error handling
add support for connected UDP sockets