加载windows socket
来源:互联网 发布:java数组冒泡排序法 编辑:程序博客网 时间:2024/04/30 02:58
C中要使用socket ,必须先要加载套接字(socket )------在VC++编译环境
在连接选项里的库文件中,添上ws2_32.lib
#include <winsock2.h> //也可以选择1.1版本,winsock.h
void preSocket( )
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
return;
}
/* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions later */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */
/* requested. */
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
WSACleanup( );
return;
}
说明: WSAStartup和WSACleanup是成对出现的,分别在使用socket的前后,一个是加载套接字库,一个是退出套接字库。
- 加载windows socket
- windows构建socket前需要加载WinSock库
- windows socket
- windows socket
- windows socket
- windows socket
- windows socket 基本知识 server socket
- windows socket 基本知识 client socket
- windows socket入门例程
- Windows Socket 入门
- windows socket函数原型
- Windows Socket API函数
- windows socket编程流程
- Windows 95 Socket
- windows socket api 说明
- 截获 Windows socket API
- Windows Socket API
- [转]Windows Socket
- 跳与不跳,转载
- FreeMarker快速上手
- 多多进来看
- 原码、反码、补码
- 垃圾收集算法(Technology Computer English)
- 加载windows socket
- 解决 Java 程序的乱码问题
- Seaside对Rails:一场从未存在的战争
- 婚礼进行曲
- 关于SQL(Technology Computer English)
- 何为“等高望远”的道理
- EPOC OPL 开发介绍(Technology Computer English)
- 类方法、实例方法、类变量、实例变量
- aa