DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦00a729903⟧ TextFile

    Length: 5577 (0x15c9)
    Types: TextFile
    Names: »B«

Derivation

└─⟦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⟧ 

TextFile

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 Client 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  
                (Server_Name      : IN String := ">Currently_Ignored<";  
                 Confidence_Level : IN Utils.Test_Level := Utils.One_Way) 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;

END Client;