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

⟦ba7a0c091⟧ Ada Source

    Length: 12288 (0x3000)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Broker_Link_Layer, seg_026cca

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 Mailbox_Msg_To_Send;
with Mailbox_Received_Msg;
with Physical_Layer;
with Protocol;
with Socket_Defs;
with Socket_Port_Manager;
with Umps_Utilities;
with Text_Io;
with Uncanvas;



package body Broker_Link_Layer is

    task body Server is

        The_Broker_Listen_Socket_Port            : Socket_Port.Object;
        The_Broker_Host_Name                     : Host_Name.Object;  
        The_Broker_Listen_Socket_Id              : Socket_Defs.Socket_Id;
        The_Task_Performing_Mailbox_Received_Msg :
           Mailbox_Received_Msg.Access_Task_Mailbox;

    begin

        accept Start (Broker_Listen_Socket_Port            : Socket_Port.Object;  
                      Task_Performing_Mailbox_Received_Msg :
                         Mailbox_Received_Msg.Access_Task_Mailbox) do

            Text_Io.Put ("Broker_Link_Layer.Server : Starting ...");

            The_Broker_Listen_Socket_Port := Broker_Listen_Socket_Port;

            The_Task_Performing_Mailbox_Received_Msg :=
               Task_Performing_Mailbox_Received_Msg;

            -- Init of the allocator number :
            Socket_Port_Manager.Init_Number;

            The_Broker_Listen_Socket_Id := Physical_Layer.Create_Server
                                              (The_Broker_Listen_Socket_Port);
            Text_Io.Put_Line ("Ok.");

        end Start;

        declare

            The_Broker_Service_Socket_Id      : Socket_Defs.Socket_Id;
            The_Buffer_To_Receive             : Low_Level_Message.Object;
            The_Number_Of_Caracteres_Received : Integer;
            Result                            : Boolean;

        begin
            loop

                -- Connection to get a message :

                Text_Io.Put
                   ("Broker_Link_Layer.Server : Wait for a connection ... ");

                The_Broker_Service_Socket_Id :=
                   Physical_Layer.Server_Wait_For_A_Connection
                      (The_Broker_Listen_Socket_Id);

                Text_Io.Put_Line (" I got it !");

                Physical_Layer.Receive_String
                   (The_Broker_Service_Socket_Id, The_Buffer_To_Receive,
                    The_Number_Of_Caracteres_Received);


                -- Examine the message to intercept a Behavior creation asking :

                if Protocol.Is_A_Kind_Of (The_Buffer_To_Receive) then
                    Text_Io.Put ("it s a protocol message...");
                    if Protocol.Is_A_Request_For_A_Behavior_Socket_Port
                          (The_Buffer_To_Receive) then
                              Text_Io.Put_Line
                                 ("it s a request for a behavior port number.");
                              Protocol.Give_A_Behavior_Socket_Port
                                 (The_Broker_Service_Socket_Id,
                                  The_Buffer_To_Receive);  
                    else
                              Text_Io.Put_Line ("it s an unknown message !");
                    end if;
                else

                    -- Normal process : send the message to the received_message_fifo :
                    Text_Io.Put_Line ("it s a normal message.");

                    The_Task_Performing_Mailbox_Received_Msg.Put
                       (The_Buffer_To_Receive, Result);
                    if Result = False then
                              Text_Io.Put_Line  
                                 ("Broker_Link_Layer.Server : Putting message into received messages fifo is impossible");
                    end if;

                end if;

                Physical_Layer.Close_Socket (The_Broker_Service_Socket_Id);

            end loop;
        end;


    end Server;





    task body Client is

        The_Task_Performing_Mailbox_Msg_To_Send :
           Mailbox_Msg_To_Send.Access_Task_Mailbox;
        The_Msg                                 : Low_Level_Message.Object;
        Result                                  : Boolean := False;
        Service_Socket_Id                       : Socket_Defs.Socket_Id;
        Number_Of_Characters_Sent               : Integer;
        The_Behavior_Socket_Port                : Socket_Port.Object;
        The_Behavior_Host_Name                  : Host_Name.Object;

    begin

        accept Start (Task_Performing_Mailbox_Msg_To_Send :
                         Mailbox_Msg_To_Send.Access_Task_Mailbox) do

            The_Task_Performing_Mailbox_Msg_To_Send :=
               Task_Performing_Mailbox_Msg_To_Send;

        end Start;

        loop
            select      -- Active wait ....

                The_Task_Performing_Mailbox_Msg_To_Send.Get (The_Msg, Result);
                if Result = True then

                    -- Look for the Behavior socket port : it lies in the fourth field of the message :

                    The_Behavior_Socket_Port :=
                       Uncanvas.Get_Handler (The_Msg.The_String);

                    if (Result = False) then
                              Text_Io.Put_Line  
                                 ("Broker_Link_Layer.Client : Getting Handler number from messages is impossible");  
                    else

                              -- Look for the Behavior host name :

                              Socket_Port_Manager.Show_Value
                                 (The_Behavior_Socket_Port,
                                  The_Behavior_Host_Name, Result);

                              if Result = False then
                              Text_Io.Put_Line  
                                 ("Broker_Link_Layer.Client : Getting Handler host-name from messages is impossible");  
                              else

                              Service_Socket_Id :=
                                 Physical_Layer.Join_Server
                                    (The_Behavior_Host_Name,
                                     The_Behavior_Socket_Port);
                              if Service_Socket_Id < 0 then
                              raise Socket_Defs.Join_Server_Error;
                              end if;  
                              Physical_Layer.Send_String
                                 (Service_Socket_Id, The_Msg,
                                  Number_Of_Characters_Sent);
                              Physical_Layer.Close_Socket (Service_Socket_Id);
                              end if;
                    end if;
                end if;
            else
                null;
            end select;
        end loop;
    end Client;


end Broker_Link_Layer;

E3 Meta Data

    nblk1=b
    nid=0
    hdr6=16
        [0x00] rec0=22 rec1=00 rec2=01 rec3=05e
        [0x01] rec0=02 rec1=00 rec2=04 rec3=002
        [0x02] rec0=1c rec1=00 rec2=0b rec3=048
        [0x03] rec0=00 rec1=00 rec2=09 rec3=008
        [0x04] rec0=15 rec1=00 rec2=0a rec3=010
        [0x05] rec0=20 rec1=00 rec2=03 rec3=066
        [0x06] rec0=0d rec1=00 rec2=02 rec3=048
        [0x07] rec0=19 rec1=00 rec2=08 rec3=068
        [0x08] rec0=02 rec1=00 rec2=07 rec3=020
        [0x09] rec0=12 rec1=00 rec2=05 rec3=012
        [0x0a] rec0=09 rec1=00 rec2=06 rec3=000
    tail 0x217213b2683ab57b1879b 0x42a00088783c7f403