def is_socket(fd):
 result = False
 file_socket = socket.fromfd(fd, socket.AF_INET, socket.SOCK_RAW)
 try:
  socket_type = file_socket.getsockopt(socket.SOL_SOCKET, socket.SO_TYPE)
 except socket.error as exc:
  exc_errno = exc.args[0]
  if (exc_errno == errno.ENOTSOCK):
   pass
  else:
   result = True
 else:
  result = True
 return result

def is_socket ( fd ) : result = False file_socket = socket . fromfd ( fd , socket . AF_INET , socket . SOCK_RAW ) try : socket_type = file_socket . getsockopt ( socket . SOL_SOCKET , socket . SO_TYPE ) except socket . error as exc : exc_errno = exc . args [ 0 ] if ( exc_errno == errno . ENOTSOCK ) : pass else : result = True else : result = True return result
determine if the file descriptor is a socket .