H
heroicdragon
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Main2;var vWsatata:WSAData; Listsocket:TSocket; serverAddr:sockaddr_in; lpfnAcceptEx:LPFN_ACCEPTEX; guidAcceptEx:TGUID; num,rcWORD; pointer;begin lpfnAcceptEx:=nil; ZeroMemory(@serveraddr,SizeOf(serverAddr)); guidAcceptEx:=WSAID_ACCEPTEX;// WSAData wsadata;// SOCKET Listsocket;// SOCKADDR_IN ServerAddr={0};// LPFN_ACCEPTEX lpfnAcceptEx=NULL;// GUID guidAcceptEx=WSAID_ACCEPTEX;//// if (WSAStartup(MAKEWORD(2,2),&wsadata))// {//// } WSAStartup(MakeWord(2,2),vWsatata);// Listsocket=WSASocket(AF_INET,SOCK_STREAM,IPPROTO_TCP,NULL,0,WSA_FLAG_OVERLAPPED); Listsocket:=WSASocket(AF_INET,SOCK_STREAM,IPPROTO_TCP,nil,0,WSA_FLAG_OVERLAPPED);//// in_addr in={0};// ServerAddr.sin_family=AF_INET;// ServerAddr.sin_port=htons(5050);//// ServerAddr.sin_addr=in;// ServerAddr.sin_addr.s_addr=htonl(INADDR_ANY); serverAddr.sin_family:=AF_INET; serverAddr.sin_port:=htons(5050); serverAddr.sin_addr.S_addr:=htonl(INADDR_ANY);//// bind(Listsocket,(sockaddr*)&ServerAddr,sizeof(ServerAddr));// bind(Listsocket,psockaddr(@serverAddr),SizeOf(serverAddr));// DWORD numBytes;// DWORD rc;// rc=WSAIoctl(Listsocket,// SIO_GET_EXTENSION_FUNCTION_POINTER,// &guidAcceptEx,// sizeof(guidAcceptEx),// &lpfnAcceptEx,// sizeof(lpfnAcceptEx),// &numBytes,// NULL,// NULL); p:=nil; rc:=WSAIoctl(Listsocket, SIO_GET_EXTENSION_FUNCTION_POINTER, @guidAcceptEx, SizeOf(guidAcceptEx), p, SizeOf(LPFN_ACCEPTEX), num, nil, nil); if rc<>0 then ShowMessage(Format('错误!<$%x>',[WSAGetLastError])); @lpfnAcceptEx:=p;// if (rc==SOCKET_ERROR)// {// MessageBox("错误");// }//}end;以上是我用DELPHI 实现的 AcceptEx 函数的调用过程,其中注释部分是用VC6实现的.问题为: 程序的最后面: RC 返回的不是0 ,P 的值也是为NIL ,也就是说明没有取到AcceptEx 函数的地址;而让人气奋的是,用同样的VC 代码,却能正确的取得AcceptEx 地址。一切都正常!