예제 #1
0
struct SysSocket *Sys_Net_CreateSocket(struct SysNetData *netdata, enum netaddrtype addrtype)
{
	struct SysSocket *s;
	int r;
	int one;

	one = 1;

	if (addrtype != NA_IPV4)
		return 0;

	s = AllocVec(sizeof(*s), MEMF_ANY);
	if (s)
	{
		s->s = socket(AF_INET, SOCK_DGRAM, 0);
		if (s->s != -1)
		{
			r = IoctlSocket(s->s, FIONBIO, (void *)&one);
			if (r == 0)
			{
				return s;
			}

			CloseSocket(s->s);
		}

		FreeVec(s);
	}

	return 0;
}
예제 #2
0
파일: highsocket.c 프로젝트: tincho4t/tesis
void SockNonBlock(int Socket)
{
#if defined(WIN32)

    unsigned long onoff=1;

    if (ioctlsocket(Socket, FIONBIO, &onoff)==SOCKET_ERROR)
        perror("ioctlsocket() fallita.");

#elif defined(SOCKETLIB)
    int onoff=1;

    s_ioctl(Socket, FIONBIO, (char *)&onoff);
    s_ioctl(Socket, FIOASYNC, (char *)&onoff);

#elif defined(BSDSOCKETLIB)
    int onoff=1;

    IoctlSocket(Socket, FIONBIO, (char *)&onoff);
    IoctlSocket(Socket, FIOASYNC, (char *)&onoff);

#elif defined(LSCO)

  int nFlags;
  
  nFlags = fcntl( Socket, F_GETFL );
  nFlags |= O_NONBLOCK;
  if( fcntl( Socket, F_SETFL, nFlags ) < 0 )
  {
    perror( "Fatal error executing nonblock" );
    exit( 1 );
  }
#elif defined(AROS)

#else

  if (fcntl(Socket, F_SETFL, FNDELAY) == -1)    {
    perror("Noblock");
    exit (1);
  }

#endif
 
}
예제 #3
0
int
main()
{
/* IoctlSocket source code */
    if (0 != IoctlSocket(0, 0, 0))
        return 1;

    ;
    return 0;
}
예제 #4
0
int Curl_nonblock(curl_socket_t sockfd,    /* operate on this */
                  int nonblock   /* TRUE or FALSE */)
{
#undef SETBLOCK
#ifdef HAVE_O_NONBLOCK
  /* most recent unix versions */
  int flags;

  flags = fcntl(sockfd, F_GETFL, 0);
  if (TRUE == nonblock)
    return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
  else
    return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
#define SETBLOCK 1
#endif

#ifdef HAVE_FIONBIO
  /* older unix versions */
  int flags;

  flags = nonblock;
  return ioctl(sockfd, FIONBIO, &flags);
#define SETBLOCK 2
#endif

#ifdef HAVE_IOCTLSOCKET
  /* Windows? */
  int flags;
  flags = nonblock;
  return ioctlsocket(sockfd, FIONBIO, &flags);
#define SETBLOCK 3
#endif

#ifdef HAVE_IOCTLSOCKET_CASE
  /* presumably for Amiga */
  return IoctlSocket(sockfd, FIONBIO, (long)nonblock);
#define SETBLOCK 4
#endif

#ifdef HAVE_SO_NONBLOCK
  /* BeOS */
  long b = nonblock ? 1 : 0;
  return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
#define SETBLOCK 5
#endif

#ifdef HAVE_DISABLED_NONBLOCKING
  return 0; /* returns success */
#define SETBLOCK 6
#endif

#ifndef SETBLOCK
#error "no non-blocking method was found/used/set"
#endif
}
예제 #5
0
파일: CurlTests.c 프로젝트: 0-wiz-0/CMake
int
main ()
{

/* IoctlSocket source code */
 int socket;
 int flags = IoctlSocket(socket, FIONBIO, (long)1);

  ;
  return 0;
}
예제 #6
0
int ioctl(int fd, unsigned int request, char *argp)
{
  int success;

  /*
   * IoctlSocket will return EBADF if the d is not socket
   */
  success = IoctlSocket(fd, request, argp);

  /*
   * Maybe the EBADF should be converted to EINVAL if the fd is an usual file?
   */

  return success;
}
예제 #7
0
/*
 * curlx_nonblock() set the given socket to either blocking or non-blocking
 * mode based on the 'nonblock' boolean argument. This function is highly
 * portable.
 */
int curlx_nonblock(curl_socket_t sockfd,    /* operate on this */
                   int nonblock   /* TRUE or FALSE */)
{
#if defined(USE_BLOCKING_SOCKETS)

    return 0; /* returns success */

#elif defined(HAVE_FCNTL_O_NONBLOCK)

    /* most recent unix versions */
    int flags;
    flags = fcntl(sockfd, F_GETFL, 0);
    if(FALSE != nonblock)
        return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
    else
        return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));

#elif defined(HAVE_IOCTL_FIONBIO)

    /* older unix versions */
    int flags;
    flags = nonblock;
    return ioctl(sockfd, FIONBIO, &flags);

#elif defined(HAVE_IOCTLSOCKET_FIONBIO)

    /* Windows */
    unsigned long flags;
    flags = nonblock;
    return ioctlsocket(sockfd, FIONBIO, &flags);

#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)

    /* Amiga */
    return IoctlSocket(sockfd, FIONBIO, (long)nonblock);

#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK)

    /* BeOS */
    long b = nonblock ? 1 : 0;
    return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));

#else
#  error "no non-blocking method was found/used/set"
#endif
}
예제 #8
0
파일: connect.c 프로젝트: Arkshine/NS
int Curl_nonblock(int socket,    /* operate on this */
                  int nonblock   /* TRUE or FALSE */)
{
#undef SETBLOCK
#ifdef HAVE_O_NONBLOCK
  int flags;

  flags = fcntl(socket, F_GETFL, 0);
  if (TRUE == nonblock)
    return fcntl(socket, F_SETFL, flags | O_NONBLOCK);
  else
    return fcntl(socket, F_SETFL, flags & (~O_NONBLOCK));
#define SETBLOCK 1
#endif

#ifdef HAVE_FIONBIO
  int flags;

  flags = nonblock;
  return ioctl(socket, FIONBIO, &flags);
#define SETBLOCK 2
#endif

#ifdef HAVE_IOCTLSOCKET
  int flags;
  flags = nonblock;
  return ioctlsocket(socket, FIONBIO, &flags);
#define SETBLOCK 3
#endif

#ifdef HAVE_IOCTLSOCKET_CASE
  return IoctlSocket(socket, FIONBIO, (long)nonblock);
#define SETBLOCK 4
#endif

#ifdef HAVE_DISABLED_NONBLOCKING
  return 0; /* returns success */
#define SETBLOCK 5
#endif

#ifndef SETBLOCK
#error "no non-blocking method was found/used/set"
#endif
}
예제 #9
0
int ioctlsocket(int sockfd, long request, char *arg)
{
#ifdef __amigaos4__
  GETISOCKET();
  if(ISocket) return ISocket->IoctlSocket(sockfd, request, arg);
  else return -1;
#elif __MORPHOS__
  GETSOCKET();
  if(SocketBase) return IoctlSocket(sockfd, request, arg);
  else return -1;
#else
	GETSTATE();

	if (state->SocketBase)
	{
		switch(state->TCPIPStackType)
		{
			case TCPIP_Miami:
			case TCPIP_AmiTCP:
			case TCPIP_MLink:
				return amitcp_IoctlSocket(sockfd, request, arg);
				break;
			case TCPIP_IN225:
				switch (request)
				{
					case SIOCADDRT	     : request = ('r'<<8)|1; break;
					case SIOCDELRT	     : request = ('r'<<8)|2; break;
					case SIOCSIFADDR     : request = ('i'<<8)|3; break;
					case SIOCGIFADDR     : request = ('i'<<8)|4; break;
					case SIOCSIFDSTADDR  : request = ('i'<<8)|5; break;
					case SIOCGIFDSTADDR  : request = ('i'<<8)|6; break;
					case SIOCSIFFLAGS    : request = ('i'<<8)|7; break;
					case SIOCGIFFLAGS    : request = ('i'<<8)|8; break;
					case SIOCGIFCONF     : request = ('i'<<8)|9; break;
/*					case SIOCSIFMTU      : request = ('i'<<8)|10; break; */
/*					case SIOCGIFMTU      : request = ('i'<<8)|11; break; */
					case SIOCGIFBRDADDR  : request = ('i'<<8)|12; break;
					case SIOCSIFBRDADDR  : request = ('i'<<8)|13; break;
					case SIOCGIFNETMASK  : request = ('i'<<8)|14; break;
					case SIOCSIFNETMASK  : request = ('i'<<8)|15; break;
					case SIOCGIFMETRIC   : request = ('i'<<8)|16; break;
					case SIOCSIFMETRIC   : request = ('i'<<8)|17; break;
#ifdef SIOCDARP
					case SIOCSARP	     : request = ('i'<<8)|18; break;
#endif /* SIOCSARP */
#ifdef SIOCGARP
					case SIOCGARP	     : request = ('i'<<8)|19; break;
#endif /* SIOCGARP */
#ifdef SIOCDARP
					case SIOCDARP	     : request = ('i'<<8)|20; break;
#endif /* SIOCDARP */
					case SIOCATMARK      : request = ('i'<<8)|21; break;
					case FIONBIO	     : request = ('m'<<8)|22; break;
					case FIONREAD	     : request = ('m'<<8)|23; break;
					case FIOASYNC	     : request = ('m'<<8)|24; break;
					case SIOCSPGRP	     : request = ('m'<<8)|25; break;
					case SIOCGPGRP	     : request = ('m'<<8)|26; break;
				}
				return in225_s_ioctl(sockfd, request, arg);
				break;
			case TCPIP_Termite:
				return termite_IoctlSocket(sockfd, request, arg);
				break;
		}
	}

	return(-1);
#endif
}