fix for Sockets.Receive
Dmitriy Anisimkov <[email protected]> Tue, 02 Mar 2004 11:59:56 +0600
| Newsgroups | gmane.comp.lang.ada.sockets |
|---|---|
| Message-ID | <[email protected]> |
Sam,
Could you please fix the Sockets.Receive routine.
When Count < 0 (error condition),
Index := Index + Stream_Element_Count (Count);
raise the Constraint_Error
and we would not know the original socket error.
----------------------------------
sh-2.04$ diff -c adasockets-1.8.4.2/src/sockets.adb adasockets/sockets.adb
*** adasockets-1.8.4.2/src/sockets.adb Thu Jan 1 21:24:54 2004
--- adasockets/sockets.adb Mon Mar 1 21:53:36 2004
***************
*** 463,475 ****
while Rest > 0 loop
Count := C_Recvfrom (Socket.FD, Data (Index) 'Address,
int (Rest), 0, Addr'Address, Addrlen'Access);
! Index := Index + Stream_Element_Count (Count);
! Rest := Rest - Stream_Element_Count (Count);
if Count < 0 then
Raise_With_Message ("Receive error");
elsif Count = 0 then
raise Connection_Closed;
end if;
end loop;
end Receive;
--- 463,477 ----
while Rest > 0 loop
Count := C_Recvfrom (Socket.FD, Data (Index) 'Address,
int (Rest), 0, Addr'Address, Addrlen'Access);
!
if Count < 0 then
Raise_With_Message ("Receive error");
elsif Count = 0 then
raise Connection_Closed;
end if;
+
+ Index := Index + Stream_Element_Count (Count);
+ Rest := Rest - Stream_Element_Count (Count);
end loop;
end Receive;
---------------------------
_______________________________________________
AdaSockets mailing list
[email protected]
http://www.rfc1149.net/mailman/listinfo/adasockets