DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

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

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦8fe087411⟧ Ada Source

    Length: 15360 (0x3c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Protocol, seg_027faa

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



with Host_Name;
with Low_Level_Message;
with Physical_Layer;
with Socket_Defs;
with Socket_Port;
with Socket_Port_Manager;
with Text_Io;




package body Protocol is

    Protocol_Header : constant String := "Protocol";
    Request_For_A_Behavior_Socket_Port : constant String :=
       Protocol_Header & "Give me a socket port";
    Response_Of_A_Request_For_A_Behavior_Socket_Port : constant String :=
       Protocol_Header & "This is your socket port : ";





    function Is_A_Kind_Of
                (The_Message : Low_Level_Message.Object) return Boolean is  
    begin
        if The_Message.The_String (1 .. Protocol_Header'Length) =
           Protocol_Header then
            return True;
        else
            return False;
        end if;

    end Is_A_Kind_Of;





    function Is_A_Request_For_A_Behavior_Socket_Port
                (The_Message : Low_Level_Message.Object) return Boolean is
    begin
        if The_Message.The_String
              (1 .. Request_For_A_Behavior_Socket_Port'Length) =
           Request_For_A_Behavior_Socket_Port then
            return True;
        else
            return False;
        end if;
    end Is_A_Request_For_A_Behavior_Socket_Port;






    function Ask_A_Behavior_Socket_Port
                (The_Broker_Socket_Id : Socket_Defs.Socket_Id)
                return Socket_Port.Object is

        The_Local_Host_Name               : Host_Name.Object;
        The_Number_Of_Characters_Sent     : Integer;  
        The_Number_Of_Characters_Received : Integer;
        The_Result                        : Socket_Port.Object;
        The_Request                       : Low_Level_Message.Object;
        The_Response                      : Low_Level_Message.Object;

    begin

        Physical_Layer.Get_Host_Name (The_Local_Host_Name);

        The_Request := Low_Level_Message.Create
                          (Request_For_A_Behavior_Socket_Port &
                           The_Local_Host_Name.The_String);

        Physical_Layer.Send_String (The_Broker_Socket_Id, The_Request,
                                    The_Number_Of_Characters_Sent);

        Text_Io.Put_Line ("Protocol : Request message sent ... ");

        Physical_Layer.Receive_String (The_Broker_Socket_Id, The_Response,
                                       The_Number_Of_Characters_Received);



        Text_Io.Put_Line ("Protocol : Response message received: " &
                          The_Response.The_String);

        if The_Response.The_String
              (1 .. Response_Of_A_Request_For_A_Behavior_Socket_Port'Length) /=
           Response_Of_A_Request_For_A_Behavior_Socket_Port then

            Text_Io.Put_Line ("Umps_Message.Init : Reception error");
            raise Socket_Defs.Create_Behavior_Error;

        else

            The_Result :=
               Socket_Port.Create
                  (Natural'Value
                      (The_Response.The_String
                          (Response_Of_A_Request_For_A_Behavior_Socket_Port'
                           Length + 1 .. The_Response.The_Size)));
            return The_Result;
        end if;

    end Ask_A_Behavior_Socket_Port;



    procedure Give_A_Behavior_Socket_Port
                 (The_Broker_Socket_Id : Socket_Defs.Socket_Id;
                  The_Buffer_Received  : Low_Level_Message.Object) is

        The_Behavior_Host_Name                : Host_Name.Object;
        The_Allocated_Behavior_Port_In_String : Low_Level_Message.Object;
        The_Buffer_To_Send_Back               : Low_Level_Message.Object;
        The_Allocated_Behavior_Port           : Socket_Port.Object;
        Number_Of_Caracteres_Sent_Back        : Integer;
        Result                                : Boolean;

    begin

        Text_Io.Put_Line ("Protocol : A behavior asked for a Behavior_Number.");

        The_Behavior_Host_Name :=
           Host_Name.Create
              (The_Buffer_Received.The_String
                  (Request_For_A_Behavior_Socket_Port'Length + 1 ..
                      The_Buffer_Received.The_String'Last));


        Text_Io.Put_Line ("Protocol : Choose a Behavior port number => ");

        Socket_Port_Manager.Allocate (The_Behavior_Host_Name,
                                      The_Allocated_Behavior_Port, Result);


        Text_Io.Put_Line ("-->" & Socket_Port.Image
                                     (The_Allocated_Behavior_Port));

        if Result = False then

            The_Allocated_Behavior_Port_In_String := Socket_Port.Undefined;
            Text_Io.Put_Line
               ("Protocol : allocate a new behavior number is impossible");

        else

            The_Allocated_Behavior_Port_In_String :=
               Socket_Port.Image (The_Allocated_Behavior_Port);

        end if;

        The_Buffer_To_Send_Back :=
           Low_Level_Message.Create
              (Response_Of_A_Request_For_A_Behavior_Socket_Port &
               The_Allocated_Behavior_Port_In_String.The_String);

        Text_Io.Put_Line ("Protocol : Send the response ...");

        Physical_Layer.Send_String
           (The_Broker_Socket_Id, The_Buffer_To_Send_Back,
            Number_Of_Caracteres_Sent_Back);

        Text_Io.Put_Line ("Protocol : OK");

    end Give_A_Behavior_Socket_Port;

end Protocol;

E3 Meta Data

    nblk1=e
    nid=c
    hdr6=c
        [0x00] rec0=2c rec1=00 rec2=01 rec3=010
        [0x01] rec0=1e rec1=00 rec2=05 rec3=048
        [0x02] rec0=1b rec1=00 rec2=03 rec3=018
        [0x03] rec0=19 rec1=00 rec2=0d rec3=000
        [0x04] rec0=1e rec1=00 rec2=07 rec3=026
        [0x05] rec0=10 rec1=00 rec2=08 rec3=000
        [0x06] rec0=06 rec1=00 rec2=07 rec3=000
        [0x07] rec0=13 rec1=00 rec2=0c rec3=000
        [0x08] rec0=17 rec1=00 rec2=05 rec3=01c
        [0x09] rec0=0a rec1=00 rec2=0a rec3=000
        [0x0a] rec0=1a rec1=00 rec2=09 rec3=000
        [0x0b] rec0=03 rec1=00 rec2=08 rec3=000
        [0x0c] rec0=07 rec1=00 rec2=05 rec3=000
        [0x0d] rec0=0f rec1=00 rec2=07 rec3=000
    tail 0x21722073683ad814973c5 0x42a0008846207f403
Free Block Chain:
  0xc: 0000  00 0a 03 fc 80 26 54 68 65 5f 42 75 66 66 65 72  ┆     &The_Buffer┆
  0xa: 0000  00 06 00 18 00 15 20 20 20 20 20 20 20 20 54 65  ┆              Te┆
  0x6: 0000  00 09 00 42 80 24 76 69 6f 72 20 61 73 6b 65 64  ┆   B $vior asked┆
  0x9: 0000  00 04 03 fc 80 0b 69 6e 67 2e 4f 62 6a 65 63 74  ┆      ing.Object┆
  0x4: 0000  00 0b 03 fc 80 1c 64 5f 42 65 68 61 76 69 6f 72  ┆      d_Behavior┆
  0xb: 0000  00 02 03 65 80 42 20 20 20 20 20 20 20 20 20 20  ┆   e B          ┆
  0x2: 0000  00 0e 00 2c 80 29 20 20 20 20 20 20 20 20 20 2d  ┆   , )         -┆
  0xe: 0000  00 00 00 0c 80 09 6f 5f 53 65 6e 64 5f 42 61 09  ┆      o_Send_Ba ┆