📄 wsinit.c
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/winagent/wsinit.c,v 1.1.1.1 2001/11/05 17:49:19 tneale Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** * Copyright 1988-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. ****************************************************************************//* * $Log: wsinit.c,v $ * Revision 1.1.1.1 2001/11/05 17:49:19 tneale * Tornado shuffle * * Revision 1.6 2001/01/19 22:25:12 paul * Update copyright. * * Revision 1.5 2000/03/17 00:15:55 meister * Update copyright message * * Revision 1.4 1998/02/25 04:58:37 sra * Update copyrights. * * Revision 1.3 1997/03/20 06:53:41 sra * DFARS-safe copyright text. Zap! * * Revision 1.2 1997/02/25 16:34:43 mrf * Added RCS log and copyright notice * *//* [clearcase]modification history-------------------01a,19apr05,job update copyright notices*//*--------------------------------------------------------- WSINIT.C -- Initializes Windows Sockets ---------------------------------------------------------*/#include "wsagent.h"SOCKET sSNMP = INVALID_SOCKET;/*--------------------------------------------------------- WS_Initialize() -- Initializes Winsock DLL and sets up listening socket. Returns SUCCESS if successful, FAILURE if not. ---------------------------------------------------------*/int WS_Initialize(HWND hwnd){ WSADATA wsadata; SOCKERR serr; serr = WSAStartup(DESIRED_WINSOCK_VERSION, &wsadata); if (serr != 0) { MsgBox (NULL, MB_ICONSTOP | MB_OK, "Cannot initialize socket library, error %d: %s", serr, SockerrToString (serr)); return FAILURE; } if (wsadata.wVersion < MINIMUM_WINSOCK_VERSION) { MsgBox (NULL, MB_ICONSTOP | MB_OK, "Unsupported Windows Sockets Version %02X.%02X.", LOBYTE(wsadata.wVersion), HIBYTE(wsadata.wVersion)); return FAILURE; } #if DEBUG MsgBox (NULL, MB_OK, "Windows Sockets DLL initialized! Version %02X.%02X", LOBYTE(wsadata.wVersion), HIBYTE(wsadata.wVersion));#endif /* DEBUG */ serr = CreateSocket (&sSNMP, SOCK_DGRAM, htonl (INADDR_ANY), htons (SNMP_PORT)); if (serr == 0) {#if DEBUG MsgBox (NULL, MB_OK, "Successfully created SNMP socket!");#endif /* DEBUG */ if (WSAAsyncSelect (sSNMP, hwnd, WM_SOCKET_SELECT, FD_READ) != 0) { serr = WSAGetLastError(); } } if (serr != 0) { MsgBox (NULL, MB_ICONSTOP | MB_OK, "Cannot create SNMP socket, error %d: %s", serr, SockerrToString (serr)); return FAILURE; } return SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -