コード例 #1
0
ファイル: sockets.c プロジェクト: NicolasPetton/smalltalk
static int
myAccept (int fd, struct sockaddr *addr, socklen_t *addrlen)
{
  SOCKET fh = SOCKET_ERROR;
  int new_fd;

  /* Parameters to system calls are not guaranteed to generate a SIGSEGV
     and for this reason we must touch them manually.  */
  _gst_grey_oop_range (addr, *addrlen);

#if defined SOCK_CLOEXEC && defined HAVE_ACCEPT4 && !defined __MSVCRT__
  if (have_sock_cloexec >= 0)
    {
      fh = accept4 (FD_TO_SOCKET (fd), addr, addrlen, SOCK_CLOEXEC);
      if (!check_have_sock_cloexec (fh, ENOSYS))
	return -1;
    }
#endif
  if (fh == SOCKET_ERROR)
    {
      fh = accept (FD_TO_SOCKET (fd), addr, addrlen);
      socket_set_cloexec (fh);
    }

  new_fd = (fh == SOCKET_ERROR ? -1 : SOCKET_TO_FD (fh));
  if (new_fd != SOCKET_ERROR)
    _gst_register_socket (new_fd, false);
  return new_fd;
}
コード例 #2
0
ファイル: sockets.c プロジェクト: NicolasPetton/smalltalk
static int
mySocket (int domain, int type, int protocol)
{
  SOCKET fh = SOCKET_ERROR;
  int fd;

#if defined SOCK_CLOEXEC && !defined __MSVCRT__
  if (have_sock_cloexec >= 0)
    {
      fh = socket (domain, type | SOCK_CLOEXEC, protocol);
      if (!check_have_sock_cloexec (fh, EINVAL))
	return -1;
    }
#endif
  if (fh == SOCKET_ERROR)
    {
      fh = socket (domain, type, protocol);
      socket_set_cloexec (fh);
    }

  fd = (fh == SOCKET_ERROR ? -1 : SOCKET_TO_FD (fh));
  if (fd != SOCKET_ERROR)
    _gst_register_socket (fd, false);
  return fd;
}
コード例 #3
0
ファイル: socket.c プロジェクト: berte/mediaplayer
int
rpl_socket (int domain, int type, int protocol)
{
  /* We have to use WSASocket() to create non-overlapped IO sockets.
     Overlapped IO sockets cannot be used with read/write.  */
  SOCKET fh = WSASocket (domain, type, protocol, NULL, 0, 0);

  if (fh == INVALID_SOCKET)
    {
      set_winsock_errno ();
      return -1;
    }
  else
    return SOCKET_TO_FD (fh);
}
コード例 #4
0
ファイル: WinPortUtils2.cpp プロジェクト: Corsaair/redtamarin
int VMPI_socket(int domain, int type, int protocol)
{
    SOCKET result;
    if( WIN32_SocketStart(2,2) == 0 )
    {
        result = socket( domain, type, protocol );
    }
    else
    {
        return -1;
    }

    if( (result == SOCKET_ERROR) || (result == INVALID_SOCKET) )
    {
        errno = WIN32_winsock_to_errno();
        return -1;
    }

    return SOCKET_TO_FD(result);
}
コード例 #5
0
ファイル: WinPortUtils2.cpp プロジェクト: Corsaair/redtamarin
// ---- C.sys.socket ---- 
int VMPI_accept(int socket, struct sockaddr *address, socklen_t *address_len)
{
    SOCKET result;
    if( WIN32_SocketStart(2,2) == 0 )
    {
        result = accept( FD_TO_SOCKET(socket), address, address_len );
    }
    else
    {
        return -1;
    }
    
    if( (result == SOCKET_ERROR) || (result == INVALID_SOCKET) )
    {
        errno = WIN32_winsock_to_errno();
        return -1;
    }

    return SOCKET_TO_FD(result);
}
コード例 #6
0
ファイル: accept.c プロジェクト: Drakey83/steamlink-sdk
int
rpl_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
{
  SOCKET sock = FD_TO_SOCKET (fd);

  if (sock == INVALID_SOCKET)
    {
      errno = EBADF;
      return -1;
    }
  else
    {
      SOCKET fh = accept (sock, addr, addrlen);
      if (fh == INVALID_SOCKET)
        {
          set_winsock_errno ();
          return -1;
        }
      else
        return SOCKET_TO_FD (fh);
    }
}