Socket问题,报错"10022'(客户端)及'10055'(服务器端)300收到源码测试正确后给分(300分)

  • 主题发起人 主题发起人 fartripLiao
  • 开始时间 开始时间
F

fartripLiao

Unregistered / Unconfirmed
GUEST, unregistred user!
1、为什么会报错
2、怎么样解决
3、我需要源码。
//请发到fartripliao@163.com
现附上相关代码
//客户端发送
if (FCltSckSendHistoryData.Host<>StrCommserver) or
(not FCltSckSendHistoryData.Active) then begin
FCltSckSendHistoryData.Active:=False;
FCltSckSendHistoryData.Host:=StrCommserver;
FCltSckSendHistoryData.Port:=12221;
FCltSckSendHistoryData.Active:=True;
BeginDate:=now;
while (Now-Begindate)*24*60*60<0.7 do
Application.ProcessMessages;
if FCltSckSendHistoryData.Active then begin
if not CanSendHistoryString then Begin //如果在连接成功前处于不能发送字符则发一个空串
FCltSckSendHistoryData.Socket.SendText(' ');
CanSendHistoryString:=True;
end;
FCltSckSendHistoryData.socket.sendtext(FSendHistoryDataText);
end
else begin
CanSendHistoryString:=False;
FCltSckSendHistoryData.Active:=False;
end;
end
else begin
if not CanSendHistoryString then Begin //如果在连接成功前处于不能发送字符则发一个空串
FCltSckSendHistoryData.Socket.SendText(' ');
CanSendHistoryString:=True;
end;
FCltSckSendHistoryData.socket.sendtext(FSendHistoryDataText);
end;
服务端 接收
// AdoTlbAcceptDataBuffer.Append;
AdoTlbAcceptDataBuffer['Acceptdata']:=Trim(Socket.ReceiveText);
AdoTlbAcceptDataBuffer.Post;

procedure TMainForm.SvrSckDataServerClientError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
ErrorCode:=0;
end;

procedure TMainForm.CltSckSendHistoryError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
CanSendHistoryString:=False;
ErrorCode:=0;
end;
 
后退
顶部