DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ B T ┃
Length: 9826 (0x2662) Types: TextFile Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦this⟧ └─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16 └─ ⟦6f12a12be⟧ »DATA« └─⟦this⟧ └─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04 └─ ⟦d65440be7⟧ »DATA« └─⟦this⟧
WITH Byte_Defs; WITH Net_Info; WITH Socket_System_Interface; WITH System_Interface; WITH System; WITH Text_Io; WITH Transport_Defs; WITH Transport; WITH Unix_Base_Types; WITH Utils; PACKAGE BODY Test_Socket_Level IS PACKAGE Log RENAMES Text_Io; FUNCTION "=" (Left : Transport_Defs.Status_Code; Right : Transport_Defs.Status_Code) RETURN Boolean RENAMES Transport_Defs."="; FUNCTION "=" (Left : Utils.Test_Level; Right : Utils.Test_Level) RETURN Boolean RENAMES Utils."="; FUNCTION ">" (L, R : Byte_Defs.Byte) RETURN Boolean RENAMES Byte_Defs.">"; FUNCTION "-" (L, R : Byte_Defs.Byte) RETURN Byte_Defs.Byte RENAMES Byte_Defs."-"; FUNCTION Byte_String_To_Integer (Bs : Byte_Defs.Byte_String) RETURN Unix_Base_Types.Int IS SEPARATE; PROCEDURE Start_Client IS The_Remote_Socket : CONSTANT Transport_Defs.Socket_Id := Net_Info.Sparc_Socket; The_Remote_Host : CONSTANT Transport_Defs.Host_Id := Net_Info.Sparc_Address; Laddr_Ptr : Socket_System_Interface.Sockaddr_In_Ptr := NEW Socket_System_Interface.Sockaddr_In' (Sin_Family => Socket_System_Interface.Af_Inet, Sin_Port => Unix_Base_Types.Ushort (Byte_String_To_Integer (Byte_Defs.Byte_String (Transport_Defs.Normalize (The_Remote_Socket)))), Sin_Addr => Unix_Base_Types.U_Long (Byte_String_To_Integer (Byte_Defs.Byte_String (Transport_Defs.Normalize (The_Remote_Host)))), Sin_Zero => (OTHERS => Ascii.Nul)); Laddrlen : Unix_Base_Types.Int := Laddr_Ptr.ALL'Size / System.Storage_Unit; Network_Socket : Unix_Base_Types.Int; System_Call_Result : Unix_Base_Types.Int; Length : Unix_Base_Types.Int; Bufsiz : CONSTANT Unix_Base_Types.Int := 1024; Buffer : Socket_System_Interface.Char_Array (0 .. Bufsiz); Buf : Unix_Base_Types.Char_Ptr; String_Buffer : String (1 .. Bufsiz); String_Length : Natural; Index : Natural; BEGIN Buf := Unix_Base_Types.To_Char_Ptr (Buffer (0)'Address); Network_Socket := Socket_System_Interface.Socket (Af => Unix_Base_Types.Int (Socket_System_Interface.Af_Inet), Socket_Type => Socket_System_Interface.Sock_Stream, Protocol => 0); IF (Network_Socket < 0) THEN Log.Put_Line (Item => "+++ Socket failed"); RETURN; ELSE Log.Put_Line ("+++ Socket created"); END IF; System_Call_Result := Socket_System_Interface.Connect (S => Network_Socket, Addr => Laddr_Ptr, Addrlen => Laddrlen); IF (System_Call_Result < 0) THEN Log.Put_Line (Item => "*** Client connect failed"); RETURN; ELSE Log.Put_Line ("+++ Client connect completed."); END IF; FOR I IN 1 .. 10 LOOP -- Text_io.Put (" Input Line: "); -- Text_Io.Get_Line (Item => String_Buffer, Last => String_Length); String_Buffer (1 .. 11) := "Hello_There"; String_Length := 11; Index := 0; FOR Len IN String_Buffer'First .. String_Buffer'First + String_Length - 1 LOOP Buffer (Index) := String_Buffer (Len); Index := Index + 1; END LOOP; Buffer (Index) := Ascii.Nul; System_Call_Result := System_Interface.File_Io.Write (Fildes => Network_Socket, Buf => Buf, Nbyte => String_Length); IF (System_Call_Result < 0) THEN Log.Put_Line (Item => "*** Client Write failed"); RETURN; ELSE Log.Put_Line ("+++ Client write completed."); END IF; System_Call_Result := System_Interface.File_Io.Read (Fildes => Network_Socket, Buf => Buf, Nbyte => String_Length); IF (System_Call_Result < 0) THEN Log.Put_Line (Item => "*** Client Read failed"); RETURN; ELSE Log.Put_Line ("+++ Client read completed."); Text_Io.Put ("Client received echo: "); FOR I IN 0 .. String_Length LOOP Text_Io.Put (Item => Buffer (I)); END LOOP; END IF; Text_Io.New_Line; END LOOP; System_Call_Result := Socket_System_Interface.Shutdown (S => Network_Socket, How => 2); IF (System_Call_Result < 0) THEN Log.Put_Line (Item => "*** Client Shutdown failed"); RETURN; ELSE Log.Put_Line ("+++ Client shutdown completed."); END IF; System_Call_Result := System_Interface.File_Io.Close (Fildes => Network_Socket); IF (System_Call_Result < 0) THEN Log.Put_Line (Item => "*** Client Close failed"); RETURN; ELSE Log.Put_Line ("+++ Client close completed."); END IF; END Start_Client; PROCEDURE Start_Server IS The_Passive_Connection : Transport.Connection_Id; The_Status : Transport_Defs.Status_Code := Transport_Defs.Disconnected; The_Network : CONSTANT Transport_Defs.Network_Name := Net_Info.Net_Name; The_Local_Socket : CONSTANT Transport_Defs.Socket_Id := Net_Info.Sparc_Socket; Messages_Received : Integer; Laddr_In_Ptr : Socket_System_Interface.Sockaddr_In_Ptr := NEW Socket_System_Interface.Sockaddr_In' (Sin_Family => Socket_System_Interface.Af_Inet, Sin_Port => Unix_Base_Types.Ushort (Byte_String_To_Integer (Byte_Defs.Byte_String (Transport_Defs.Normalize (The_Local_Socket)))), Sin_Addr => Socket_System_Interface.Inaddr_Any, Sin_Zero => (OTHERS => Ascii.Nul)); Laddrlen : Unix_Base_Types.Int := Laddr_In_Ptr.ALL'Size / System.Storage_Unit; Laddr_Ptr : Socket_System_Interface.Sockaddr_Ptr := NEW Socket_System_Interface.Sockaddr; Laddrlen_Ptr : Socket_System_Interface.Int_Ptr := NEW Unix_Base_Types.Int; Network_Socket : Unix_Base_Types.Int; Tcp_Connection : Unix_Base_Types.Int; System_Call_Result : Unix_Base_Types.Int; Length : Unix_Base_Types.Int; Bufsiz : CONSTANT Unix_Base_Types.Int := 1024; Buffer : Socket_System_Interface.Char_Array (0 .. Bufsiz); Buf : Unix_Base_Types.Char_Ptr; BEGIN Buf := Unix_Base_Types.To_Char_Ptr (Buffer (Buffer'First)'Address); Network_Socket := Socket_System_Interface.Socket (Af => Unix_Base_Types.Int (Socket_System_Interface.Af_Inet), Socket_Type => Socket_System_Interface.Sock_Stream, Protocol => 0); IF (Network_Socket < 0) THEN Log.Put_Line (Item => "+++ Socket failed"); RETURN; ELSE Log.Put_Line ("+++ Socket created"); END IF; System_Call_Result := Socket_System_Interface.Bind (S => Network_Socket, Addr => Laddr_In_Ptr, Addrlen => Laddrlen); IF (System_Call_Result < 0) THEN Log.Put_Line (Item => "+++ Bind failed"); RETURN; ELSE Log.Put_Line ("+++ Bind completed."); END IF; System_Call_Result := Socket_System_Interface.Listen (S => Network_Socket, Backlog => 5); LOOP Tcp_Connection := Socket_System_Interface.Saccept (S => Network_Socket, Addr => Laddr_Ptr, Addrlen => Laddrlen_Ptr); IF Tcp_Connection < 0 THEN Log.Put_Line ("*** Server Accept failed."); RETURN; ELSE Log.Put_Line ("+++ Server Accept completed."); END IF; LOOP Length := System_Interface.File_Io.Read (Fildes => Tcp_Connection, Buf => Buf, Nbyte => Bufsiz); IF Length <= 0 THEN Log.Put_Line ("*** Server read failed. Status = " & Integer'Image (Integer (Length))); EXIT; ELSE System_Call_Result := System_Interface.File_Io.Write (Fildes => Tcp_Connection, Buf => Buf, Nbyte => Length); IF System_Call_Result < 0 THEN Log.Put_Line ("*** Server write failed. Result = " & Integer'Image (System_Call_Result)); EXIT; ELSIF System_Call_Result /= Length THEN Log.Put_Line ("++* Server write Length /= Result." & " Bytes written = " & Integer'Image (System_Call_Result)); END IF; END IF; END LOOP; System_Call_Result := System_Interface.File_Io.Close (Fildes => Tcp_Connection); END LOOP; END Start_Server; END Test_Socket_Level;