* Applied patch by Markus Kaemmerer: Fixes fdRead and fdWrite

This commit is contained in:
sg 2000-07-28 08:43:46 +00:00
parent ba86afd3b0
commit 9c88b8f0cb

View File

@ -172,25 +172,23 @@ end;
{ mimic the linux fdWrite/fdRead calls for the file/text socket wrapper } { mimic the linux fdWrite/fdRead calls for the file/text socket wrapper }
function fdWrite(handle : longint;var bufptr;size : dword) : dword; function fdWrite(handle : longint;var bufptr;size : dword) : dword;
begin
var fdWrite := WinSock.send(handle, bufptr, size, 0);
d : dword; if fdWrite = SOCKET_ERROR then
begin begin
if not(Windows.WriteFile(handle,bufptr,size,d,nil)) then SocketError := WSAGetLastError;
SocketError:=Windows.GetLastError fdWrite := 0;
else end
SocketError:=0; else
fdWrite:=d; SocketError := 0;
end; end;
function fdRead(handle : longint;var bufptr;size : dword) : dword; function fdRead(handle : longint;var bufptr;size : dword) : dword;
var var
d : dword; d : dword;
begin begin
if ioctlsocket(handle,FIONREAD,@d)<>0 then if ioctlsocket(handle,FIONREAD,@d) = SOCKET_ERROR then
begin begin
SocketError:=WSAGetLastError; SocketError:=WSAGetLastError;
fdRead:=0; fdRead:=0;
@ -200,14 +198,16 @@ function fdRead(handle : longint;var bufptr;size : dword) : dword;
begin begin
if size>d then if size>d then
size:=d; size:=d;
if not(Windows.ReadFile(handle,bufptr,size,d,nil)) then fdRead := WinSock.recv(handle, bufptr, size, 0);
SocketError:=Windows.GetLastError if fdRead = SOCKET_ERROR then
else begin
SocketError:= WSAGetLastError;
fdRead := 0;
end else
SocketError:=0; SocketError:=0;
end end
else else
SocketError:=0; SocketError:=0;
fdRead:=d;
end; end;
@ -224,7 +224,10 @@ finalization
end. end.
{ {
$Log$ $Log$
Revision 1.3 2000-07-28 06:34:53 sg Revision 1.4 2000-07-28 08:43:46 sg
* Applied patch by Markus Kaemmerer: Fixes fdRead and fdWrite
Revision 1.3 2000/07/28 06:34:53 sg
* Applied patch to "Connect" by Markus Kaemmerer: WinSock.Connect returns * Applied patch to "Connect" by Markus Kaemmerer: WinSock.Connect returns
zero when it succeeded, and not vice versa. zero when it succeeded, and not vice versa.