示例#1
0
int checksocketlib(void)
{
	if(!SocketBase)
	{
		if(SocketBase=OpenLibrary("bsdsocket.library",4))
		{
			/*
			 * Succesfull. Now tell bsdsocket.library:
			 * - the address of our errno
			 * - the address of our h_errno
			 * - our program name
			 */
			SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), &errno,
						   SBTM_SETVAL(SBTC_HERRNOLONGPTR), &h_errno,
						   SBTM_SETVAL(SBTC_LOGTAGPTR), "Python",
						   TAG_END);
		}
		else
		{
			PyErr_SetString(PyExc_SystemError, "Couldn't open bsdsocket.library (start AmiTCP)");
			return 0;
		}
	}
	return 1;
}
BOOL amiga_init()
{
  if(!SocketBase)
    SocketBase = OpenLibrary("bsdsocket.library", 4);
  
  if(!SocketBase) {
    __request("No TCP/IP Stack running!");
    return FALSE;
  }
  
  if(SocketBaseTags(
    SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG) &errno,
//    SBTM_SETVAL(SBTC_HERRNOLONGPTR),     (ULONG) &h_errno,
    SBTM_SETVAL(SBTC_LOGTAGPTR),       (ULONG) "cURL",
  TAG_DONE)) {
    
    __request("SocketBaseTags ERROR");
    return FALSE;
  }
  
#ifndef __libnix__
  atexit(amiga_cleanup);
#endif
  
  return TRUE;
}
示例#3
0
void aros_init_socket(void)
{
  if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) {
    printf("NoTCP/IP Stack available");
    exit(10);
  }
  if (SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))),
                     (IPTR)&errno,
                     SBTM_SETVAL(SBTC_HERRNOLONGPTR),
                     (IPTR)&h_errno, TAG_DONE)) {
    printf("Failed to set ERRNO");
    exit(10);
  }
}
示例#4
0
文件: net_ip.c 项目: Ododo/etlegacy
/*
====================
NET_Init
====================
*/
void NET_Init(void)
{
#ifdef _WIN32
	int r;

	r = WSAStartup(MAKEWORD(1, 1), &winsockdata);
	if (r)
	{
		Com_Printf("WARNING: NET_Init: Winsock initialization failed, returned %d\n", r);
		return;
	}

	winsockInitialized = qtrue;
	Com_Printf("Winsock initialized.\n");
#endif
#if defined(__AROS__) || defined(__MORPHOS__)
	SocketBase = OpenLibrary("bsdsocket.library", 0);
	if (!SocketBase)
	{
		Com_Printf("WARNING: NET_Init - Unable to open bsdsocket.library\n");
		return;
	}

	if (SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (IPTR)&errno, TAG_DONE))
	{
		CloseLibrary(SocketBase);
		SocketBase = NULL;
		Com_Printf("WARNING: NET_Init - SocketBaseTags failed\n");
		return;
	}
#endif

	NET_Config(qtrue);

	Cmd_AddCommand("net_restart", NET_Restart_f);

	Com_Printf("Network initialized.\n");
}