check_socket_flag(int sock_flag, int fd_flag, int fs_flag)
{
  int sock_fd, fd_flags, fs_flags;

  sock_fd = socket(AF_INET, SOCK_DGRAM | sock_flag, 0);
  if (sock_fd < 0)
    return 0;

  fd_flags = fcntl(sock_fd, F_GETFD);
  fs_flags = fcntl(sock_fd, F_GETFL);

  close(sock_fd);

  if (fd_flags == -1 || (fd_flags & fd_flag) != fd_flag ||
      fs_flags == -1 || (fs_flags & fs_flag) != fs_flag)
    return 0;

  return 1;
}
check_socket_flag(int sock_flag, int fd_flag, int fs_flag)
{
  int sock_fd, fd_flags, fs_flags;

  sock_fd = socket(AF_INET, SOCK_DGRAM | sock_flag, 0);
  if (sock_fd < 0)
    return 0;

  fd_flags = fcntl(sock_fd, F_GETFD);
  fs_flags = fcntl(sock_fd, F_GETFL);

  close(sock_fd);

  if (fd_flags == -1 || (fd_flags & fd_flag) != fd_flag ||
      fs_flags == -1 || (fs_flags & fs_flag) != fs_flag)
    return 0;

  return 1;
}