首页 > 编程知识 正文

websocket是什么意思(websocket没准备好)

时间:2023-05-03 06:02:57 阅读:72588 作者:899

我写了很多插座,但我不太关注插座的第一步

# define win32 _ lean _ and _ mean # include windows.h # include Winsock2. h # include ws2 tcpip.h # include stdio.h/nclude WSADATA wsaData; int err;/* usethemakeword (低字节,高字节) macrodeclaredinwindef.h */wversion requested=make word ) 2,2 ); err=wsa startup (wversion requested,wsaData ); if(err!=0()/* telltheuserthatwecouldnotfindausable (/* Winsock dll.*/printf (wsastartupfailedwitherror 3360 % dn ' retu n ) }/* confirmthatthewinsockdllsupports 2.2.*//* notethatifthedllsupportsversionsgreater */* than 2.2 inadditionto 2.2, itwillstillreturn *//* 2.2 inwversionsincethatistheversionwe *//* requested.*/if (lobyte (wsadata.wversion )!=2||(wsadata.wversion )!=2()/* telltheuserthatwecouldnotfindausable )/*winsockdll.*/printf ) couldnotfindausableversionofwinsock.dll wsacach 返回1; } else printf (the Winsock 2.2 dllwasfoundokay (n );/* thewinsockdllisacceptable.proceedtouseit.*//* addnetworkprogrammingusingwinsockhere */* thencallwsacleanupwhendhere

WSAStartup入手:

int wsa startup (wordwversionrequired,LPWSADATA lpWSAData ); 通过调用此WSAStartup函数,初始化使用Winsock DLL的进程的使用信息

第一个参数不需要关注。

typedefstructwsadata { word wversion; 魔兽世界; } WSADATA; 此WSADATA结构包含在windows套接字实现信息中。 其他字段只用于兼容版本。 从socket2开始,只有这两个字段有意义。 就是创建soocket的版本号。

如果APP应用程序或DLL成功调用WSAStartup,则可以根据需要继续进行其他Windows套接字调用。 使用Winsock DLL的服务完成后,APP应用程序必须调用WSACleanup,以便Winsock DLL释放APP应用程序使用的内部Winsock资源。

每次成功调用WSAStartup函数时,APP应用程序都必须调用WSACleanup函数。 例如,如果一个APP应用程序调用WSAStartup3次,则意味着必须调用WSACleanup3次。WSACleanup中的前两个调用除了减少内部计数器外没有任何效果。 此任务的最后一次WSACleanup调用完成了此任务所需的所有资源的重新分配。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。