Z
zj_uu
Unregistered / Unconfirmed
GUEST, unregistred user!
服务器程序用VC编写,在内网上运行
客户端程序用Delphi6编写,是一个Dll,外围程序调用Dll时,Dll中生成一个线程和TClientSocket,
结果在外网的机器上运行都是正常的,但是在部分内网的机器上运行时却发现TClientSocket连接服务器失败,
不过其实隔一会以后服务器都能收到连接信息,但这时客户端已经连接超时了
下面是部分代码
CurrentThread:=MyThread.Create(True);
with CurrentThread do
begin
FreeOnTerminate:=True;
Socket:=TClientSocket.Create(Application);
Socket.ClientType:=ctNonBlocking;
Socket.Host:=IP;
Socket.Port:=Port;
Socket.OnDisconnect:=SocketDisconnect;
Socket.OnError:=SocketError;
try
Socket.Active:=True;
except
Terminate;
Result:=ConnectFailed;
Exit;
end;
WaitCount:=0;
while (not Socket.Active) and (WaitCount<600) do
begin
Sleep(10);
Inc(WaitCount);
Application.ProcessMessages;
end;
if not Socket.Active then
begin
Terminate;
CurrentThread:=nil;
Result:=ConnectFailed;
Exit;
end;
客户端程序用Delphi6编写,是一个Dll,外围程序调用Dll时,Dll中生成一个线程和TClientSocket,
结果在外网的机器上运行都是正常的,但是在部分内网的机器上运行时却发现TClientSocket连接服务器失败,
不过其实隔一会以后服务器都能收到连接信息,但这时客户端已经连接超时了
下面是部分代码
CurrentThread:=MyThread.Create(True);
with CurrentThread do
begin
FreeOnTerminate:=True;
Socket:=TClientSocket.Create(Application);
Socket.ClientType:=ctNonBlocking;
Socket.Host:=IP;
Socket.Port:=Port;
Socket.OnDisconnect:=SocketDisconnect;
Socket.OnError:=SocketError;
try
Socket.Active:=True;
except
Terminate;
Result:=ConnectFailed;
Exit;
end;
WaitCount:=0;
while (not Socket.Active) and (WaitCount<600) do
begin
Sleep(10);
Inc(WaitCount);
Application.ProcessMessages;
end;
if not Socket.Active then
begin
Terminate;
CurrentThread:=nil;
Result:=ConnectFailed;
Exit;
end;