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

⟦81bf8d0a1⟧ TextFile

    Length: 8818 (0x2272)
    Types: TextFile
    Names: »B«

Derivation

└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13
    └─ ⟦124ff5788⟧ »DATA« 
        └─⟦this⟧ 
└─⟦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 My_String;
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";


-- TO CHANGE : KEEP AWAY THE PORT NUMBER !

    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 : My_String.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 : My_String.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               : My_String.Object;
        The_Number_Of_Characters_Sent     : Integer;  
        The_Number_Of_Characters_Received : Integer;
        The_Request                       : My_String.Object;
        The_Response                      : My_String.Object;
        The_Result                        : Socket_Port.Object;

    begin

        Physical_Layer.Get_Host_Name (The_Local_Host_Name);

        The_Request :=
           My_String.Object'
              (The_Size   => Request_For_A_Behavior_Socket_Port'Length +
                                The_Local_Host_Name.The_Size,
               The_String => (others => ' '));

        The_Request.The_String := 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 ("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)));
        end if;

        return The_Result;

    end Ask_A_Behavior_Socket_Port;



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

        The_Behavior_Host_Name                : My_String.Object;
        The_Allocated_Behavior_Port           : Socket_Port.Object;
        The_Allocated_Behavior_Port_In_String : My_String.Object;
        The_Buffer_To_Send_Back               : My_String.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 := My_String.Object'
        --                              (The_Size => Socket_Defs.Host_Name_Length,
        --                               The_String => (others => ' '));
        -- The_Behavior_Host_Name.The_String :=
        --    The_Buffer_Received.The_String
        --       (Request_For_A_Behavior_Socket_Port'Length + 1 ..
        --           Request_For_A_Behavior_Socket_Port'Length +
        --              Socket_Defs.Host_Name_Length);
        --
        --
        Text_Io.Put ("Protocol : Choose a Behavior port number => ");

        -- Socket_Port_Manager.Allocate (The_Behavior_Host_Name,
        --                               The_Allocated_Behavior_Port, Result);
        --

        The_Allocated_Behavior_Port := Socket_Port.Create (5110);
        Result                      := True;

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


        The_Buffer_To_Send_Back :=
           My_String.Object'
              (The_Size   =>
                  Response_Of_A_Request_For_A_Behavior_Socket_Port'Length,
               The_String => (others => ' '));

        The_Buffer_To_Send_Back.The_String :=
           Response_Of_A_Request_For_A_Behavior_Socket_Port;

        if Result = False then

            -- The_Allocated_Behavior_Port_In_String := Socket_Port.Undefined;

            -- The_Buffer_To_Send_Back :=
            --    My_String."&" (The_Buffer_To_Send_Back,
            --                   The_Allocated_Behavior_Port_In_String);
            --
            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);

            The_Buffer_To_Send_Back :=
               My_String."&" (The_Buffer_To_Send_Back,
                              The_Allocated_Behavior_Port_In_String);


        end if;

        Text_Io.Put ("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 ("OK");

    end Give_A_Behavior_Socket_Port;





    -- procedure Give_A_Behavior_Socket_Port
    --              (The_Broker_Socket_Id : Socket_Defs.Socket_Id;
    --               The_Buffer_Received  : My_String.Object) is
    --
    --     The_Behavior_Host_Name                : My_String.Object;
    --     The_Allocated_Behavior_Port           : Socket_Port.Object;
    --     The_Allocated_Behavior_Port_In_String : My_String.Object;
    --     The_Buffer_To_Send_Back               : My_String.Object;
    --     Number_Of_Caracteres_Sent_Back        : Integer;
    --     Result                                : Boolean;
    --
    -- begin
    --
    --     Text_Io.Put_Line ("Protocol : A behavior asked for a Behavior_Number.");
    --
    --     Text_Io.Put_Line ("buf : " & The_Buffer_Received.The_String
    --                                     (1 .. The_Buffer_Received.The_Size));
    --
    --     The_Behavior_Host_Name := My_String.Object'
    --                                  (The_Size => 9, The_String => "belladone");
    --
    --
    --     Text_Io.Put ("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));
    --
    --
    --
    --     -- The_Behavior_Host_Name :=
    --     --    My_String.Object'
    --     --       (The_Size   => The_Buffer_Received.The_Size -
    --     --                         Request_For_A_Behavior_Socket_Port'Length,
    --     --        The_String => The_Buffer_Received.The_String
    --     --                         (The_Buffer_Received.The_String'First +
    --     --                          Request_For_A_Behavior_Socket_Port'Length ..
    --     --                             The_Buffer_Received.The_String'Last));
    --
    --
    --     -- The_Allocated_Behavior_Port_In_String := Socket_Port.Undefined;
    --     --
    --     -- The_Buffer_To_Send_Back :=
    --     --    My_String."&" (The_Buffer_To_Send_Back,
    --     --                   The_Allocated_Behavior_Port_In_String);
    --
    --     Text_Io.Put ("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 ("OK");
    --
    -- end Give_A_Behavior_Socket_Port;
    --
    --
    --
end Protocol;