function MyConnect : boolean;
begin
mWSocket := TWSocket.Create(nil);
mWSocket.OnDnsLookupDone := MyWSocketDnsLookupDone;
mWSocket.OnSessionConnected := MyWSocketSessionConnected;
mWSocket.LingerOnOff := wsLingerOn;
mWSocket.LingerTimeout := 0;
mWSocket.LocalPort := 3800;
mWSocket.DnsLookup(FHost);
end;
procedure MyWSocketDnsLookupDone(Sender: TObject; Error: Word);
begin
mWSocket.Addr := mWSocket.DnsResult;
mWSocket.Port := FServerPort;
mWSocket.Proto := 'tcp';
mWSocket.Connect;
end;
procedure MyWSocketSessionConnected(Sender: TObject;Error: Word);
begin
if Error <> 0 then
begin
//出现10048错误
end
else
begin
mWSocket.SetLingerOption;
end;
end;
以上是我的简单代码,如果我用mWSocket.close结束连接,立即再连接,就出现10048,
以上代码要如何修改可以避免该错误,我是使用ics的wsocket.
大家帮帮忙!!!