K
kingkeen
Unregistered / Unconfirmed
GUEST, unregistred user!
请教:
我在线程类中动态生成一个clientsocket,其Onread事件指向我自己定义的函数;
大概代码如下:
***********************************************************************************
procedure TSPConn.Execute;
begin
SubmitFlag := false;
if OpenSocket then
begin
SubmmitLoginMSG;
end;
while true do
begin
if SubmitFlag then
SendMSG;
application.ProcessMessages;
sleep(10);
end;
end;
//打开socket连接
function TSPConn.OpenSocket: boolean;
var
ETime : TDateTime;
begin
SPClientSock := TClientSocket.Create(nil);
SPClientSock.Address := mPara.ISMG.ISMGAddress;
SPClientSock.Port := mPara.ISMG.ISMGPort;
SPClientSock.Name := mPara.CSocketName;
SPClientSock.OnError := MySocketError;
SPClientSock.OnRead := MySocketRead;
ETime := now;
try
SPClientSock.Open;
while (now-ETime)< 5/86400 do
begin
if SPClientSock.Active then
break;
application.ProcessMessages;
end;
except
on e: exception do
begin
DisplayMSG('Socket exception'+#13+#10+' Open failed!!');
exit;
end;
end;
if SPClientSock.Active then
result := true
else
result := false;
end;
//自定义ClientSocket的Onread事件
procedure TSPConn.MySocketRead(Sender: TObject; Socket: TCustomWinSocket);
var
ReadBufSize: integer;
begin
{数据处理}
end;
********************************************************************************************
当我连接由delphi编写的server端程序时,clientsocket收发数据一切正常;当我连接由其他语言(VC++等)编写的server端程序时,clientsocket发送数据正常,而无法接收数据。
百思不得其解,请各位高手帮忙!!!!!!
我在线程类中动态生成一个clientsocket,其Onread事件指向我自己定义的函数;
大概代码如下:
***********************************************************************************
procedure TSPConn.Execute;
begin
SubmitFlag := false;
if OpenSocket then
begin
SubmmitLoginMSG;
end;
while true do
begin
if SubmitFlag then
SendMSG;
application.ProcessMessages;
sleep(10);
end;
end;
//打开socket连接
function TSPConn.OpenSocket: boolean;
var
ETime : TDateTime;
begin
SPClientSock := TClientSocket.Create(nil);
SPClientSock.Address := mPara.ISMG.ISMGAddress;
SPClientSock.Port := mPara.ISMG.ISMGPort;
SPClientSock.Name := mPara.CSocketName;
SPClientSock.OnError := MySocketError;
SPClientSock.OnRead := MySocketRead;
ETime := now;
try
SPClientSock.Open;
while (now-ETime)< 5/86400 do
begin
if SPClientSock.Active then
break;
application.ProcessMessages;
end;
except
on e: exception do
begin
DisplayMSG('Socket exception'+#13+#10+' Open failed!!');
exit;
end;
end;
if SPClientSock.Active then
result := true
else
result := false;
end;
//自定义ClientSocket的Onread事件
procedure TSPConn.MySocketRead(Sender: TObject; Socket: TCustomWinSocket);
var
ReadBufSize: integer;
begin
{数据处理}
end;
********************************************************************************************
当我连接由delphi编写的server端程序时,clientsocket收发数据一切正常;当我连接由其他语言(VC++等)编写的server端程序时,clientsocket发送数据正常,而无法接收数据。
百思不得其解,请各位高手帮忙!!!!!!