|
@@ -1,4 +1,4 @@
|
|
-{ lNet v0.5.5
|
|
|
|
|
|
+{ lNet v0.5.6
|
|
|
|
|
|
CopyRight (C) 2004-2006 Ales Katona
|
|
CopyRight (C) 2004-2006 Ales Katona
|
|
|
|
|
|
@@ -446,7 +446,7 @@ end;
|
|
|
|
|
|
function TLSocket.Bail(const msg: string; const ernum: Integer): Boolean;
|
|
function TLSocket.Bail(const msg: string; const ernum: Integer): Boolean;
|
|
begin
|
|
begin
|
|
- Result := False; // return the result for the caller
|
|
|
|
|
|
+ Result := False; // return the result for the caller
|
|
|
|
|
|
Disconnect;
|
|
Disconnect;
|
|
LogError(msg, ernum);
|
|
LogError(msg, ernum);
|
|
@@ -505,7 +505,8 @@ end;
|
|
|
|
|
|
function TLSocket.Get(var aData; const aSize: Integer): Integer;
|
|
function TLSocket.Get(var aData; const aSize: Integer): Integer;
|
|
var
|
|
var
|
|
- AddressLength: Integer = SizeOf(FAddress);
|
|
|
|
|
|
+ AddressLength: Integer = SizeOf(FPeerAddress);
|
|
|
|
+ LastError: Longint;
|
|
begin
|
|
begin
|
|
Result := 0;
|
|
Result := 0;
|
|
if CanReceive then begin
|
|
if CanReceive then begin
|
|
@@ -516,10 +517,12 @@ begin
|
|
if Result = 0 then
|
|
if Result = 0 then
|
|
Disconnect;
|
|
Disconnect;
|
|
if Result = SOCKET_ERROR then begin
|
|
if Result = SOCKET_ERROR then begin
|
|
- if IsBlockError(LSocketError) then begin
|
|
|
|
|
|
+ LastError := LSocketError;
|
|
|
|
+ if IsBlockError(LastError) then begin
|
|
FCanReceive := False;
|
|
FCanReceive := False;
|
|
IgnoreRead := False;
|
|
IgnoreRead := False;
|
|
- end else Bail('Receive Error', LSocketError);
|
|
|
|
|
|
+ end else
|
|
|
|
+ Bail('Receive Error', LastError);
|
|
Result := 0;
|
|
Result := 0;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -622,6 +625,8 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TLSocket.Send(const aData; const aSize: Integer): Integer;
|
|
function TLSocket.Send(const aData; const aSize: Integer): Integer;
|
|
|
|
+var
|
|
|
|
+ LastError: Longint;
|
|
begin
|
|
begin
|
|
Result := 0;
|
|
Result := 0;
|
|
if not FServerSocket then begin
|
|
if not FServerSocket then begin
|
|
@@ -633,11 +638,12 @@ begin
|
|
if CanSend then begin
|
|
if CanSend then begin
|
|
Result := DoSend(aData, aSize);
|
|
Result := DoSend(aData, aSize);
|
|
if Result = SOCKET_ERROR then begin
|
|
if Result = SOCKET_ERROR then begin
|
|
- if IsBlockError(LSocketError) then begin
|
|
|
|
|
|
+ LastError := LSocketError;
|
|
|
|
+ if IsBlockError(LastError) then begin
|
|
FCanSend := False;
|
|
FCanSend := False;
|
|
IgnoreWrite := False;
|
|
IgnoreWrite := False;
|
|
end else
|
|
end else
|
|
- Bail('Send error', LSocketError);
|
|
|
|
|
|
+ Bail('Send error', LastError);
|
|
Result := 0;
|
|
Result := 0;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -849,7 +855,7 @@ procedure TLUdp.Disconnect;
|
|
begin
|
|
begin
|
|
if Assigned(FRootSock) then begin
|
|
if Assigned(FRootSock) then begin
|
|
FRootSock.Disconnect;
|
|
FRootSock.Disconnect;
|
|
- FreeAndNil(FRootSock);
|
|
|
|
|
|
+ FRootSock := nil; // even if the old one exists, eventer takes care of it
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1042,7 +1048,7 @@ begin
|
|
FIterator := FRootSock;
|
|
FIterator := FRootSock;
|
|
RegisterWithEventer;
|
|
RegisterWithEventer;
|
|
end else begin
|
|
end else begin
|
|
- FreeAndNil(FRootSock);
|
|
|
|
|
|
+ FreeAndNil(FRootSock); // one possible use, since we're not in eventer yet
|
|
FIterator := nil;
|
|
FIterator := nil;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|