Add check for socket
Add check for rstrip()