R
rainker
Unregistered / Unconfirmed
GUEST, unregistred user!
function Scanthread.ScanTCPPort(ipstr : string; Port: DWORD): Boolean;var wVersionrequested:Word; wData:WSADATA; err:integer; sockClient:TSocket; addrSrv:sockaddr_in;begin Result:=False; wVersionrequested:=MAKEWORD(1,1); err:=WSAStartup(wVersionrequested,wData); if err<>0 then Exit; if ((LOBYTE(wData.wVersion)<>1) or (HIBYTE(wData.wVersion)<>1)) then begin WSACleanup(); exit; end; try sockClient:=socket(AF_INET,SOCK_STREAM,0); addrSrv.sin_family:=AF_INET; addrSrv.sin_port:=htons(port); addrSrv.sin_addr.S_addr:=inet_addr(PChar(ipstr)); Result:=connect(sockClient,addrSrv,SizeOf(addrSrv))=0; finally closesocket(sockClient); WSACleanup(); end;end;论坛里一个高人指点的端口扫描函数.. 但是有个小问题..我扫描同几个IP, 有时返回TRUE, 有时返回FALSE. 哭...请高人在原函数上修改下. 加个超时连接. 使其准确. 谢谢了.