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

⟦1563f45fa⟧ TextFile

    Length: 5320 (0x14c8)
    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 Text_Io;

with Socket_Defs;

with Interface_C;
use Interface_C;

with Umps_Parser;

with My_Utilities;

with Fifo_Received_Msg;
with Fifo_Msg_To_Send;



package body Behavior_Tasks is
    task body Behavior_Server_Task is

        Listen_Socket_Id  : Socket_Defs.Socket_Id := -1;
        Service_Socket_Id : Socket_Defs.Socket_Id;

        The_Task_Performing_Fifo_Received_Msg :
           Fifo_Received_Msg.Access_Task_Fifo;

        The_Msg                       : Socket_Defs.Msg;
        Buffer_To_Receive             : Socket_Defs.Msg;
        Length_Of_Buffer_To_Receive   : Integer := Socket_Defs.Msg_Length;
        Number_Of_Caracteres_Received : Integer;

        Result : Boolean := False;

    begin

        accept Start (Listen_Socket_Port : Socket_Defs.Socket_Port;
                      Task_Performing_Fifo_Received_Msg :
                         Fifo_Received_Msg.Access_Task_Fifo) do

            Listen_Socket_Id := Create_Server (Listen_Socket_Port);
            The_Task_Performing_Fifo_Received_Msg :=
               Task_Performing_Fifo_Received_Msg;
        end Start;

        loop

            -- Text_Io.Put_Line ("wait...");
            Service_Socket_Id :=
               Server_Wait_For_A_Connection (Listen_Socket_Id);
            -- Text_Io.Put_Line ("...connection !");
            --
            --
            Receive_String (Service_Socket_Id, Buffer_To_Receive,
                            Length_Of_Buffer_To_Receive,
                            Number_Of_Caracteres_Received);
            -- Text_Io.Put_Line ("Get !");


            -- Control if the received message is a PROTOCOL MESSAGE :

            if Buffer_To_Receive (1 .. 9) = "PROTOCOL " then

                if Buffer_To_Receive (10 .. 25) = "GIVE_ME_A_NUMBER" then

                    declare

                        The_Response              : Socket_Defs.Msg;
                        The_Allocated_Number      : Integer;
                        Number_Of_Caracteres_Sent : Integer;

                    begin

                        Text_Io.Put_Line ("Broker received :GIVE_ME_A_NUMBER");

                        -- TO CHANGE : It should be a call to the task Number Allocator.
                        The_Allocated_Number := 9997;

                        The_Response := Integer'Image (The_Allocated_Number);

                        Send_String (Service_Socket_Id, The_Response,
                                     Socket_Defs.Msg_Length,
                                     Number_Of_Caracteres_Sent);
                        Close_Socket (Service_Socket_Id);
                    end;
                else
                    Text_Io.Put_Line ("Broker received : ????");
                end if;
            else

                Close_Socket (Service_Socket_Id);
                -- Text_Io.Put_Line ("close !");
                --
                --


                My_Utilities.Normalize (Buffer_To_Receive, The_Msg);

                -- Send the received message to the task witch perform the received message :

                The_Task_Performing_Fifo_Received_Msg.Put (The_Msg, Result);
                if Result = False then
                    raise Socket_Defs.Put_Into_Fifo_Error;
                end if;
                -- Text_Io.Put_Line ("Put into fifo !");
                --
                --
            end if;
        end loop;

    end Behavior_Server_Task;


    task body Behavior_Client_Task is

        The_Msg : Socket_Defs.Msg;
        Result : Boolean := False;
        Service_Socket_Id : Socket_Defs.Socket_Id;
        Number_Of_Caracteres_Sent : Integer;
        The_Task_Performing_Fifo_Msg_To_Send :
           Fifo_Msg_To_Send.Access_Task_Fifo;
        The_Remote_Server_Listen_Socket_Port : Socket_Defs.Socket_Port;
        The_Remote_Server_Host_Name : Socket_Defs.Host_Name;
    begin

        accept Start (Task_Performing_Fifo_Msg_To_Send :
                         Fifo_Msg_To_Send.Access_Task_Fifo) do


            The_Task_Performing_Fifo_Msg_To_Send :=
               Task_Performing_Fifo_Msg_To_Send;


        end Start;

        loop
            select      -- Active wait ....

                The_Task_Performing_Fifo_Msg_To_Send.Get (The_Msg, Result);
                if Result = False then
                    raise Socket_Defs.Get_From_Fifo_Error;
                end if;

                declare
                    The_Remote_Server_Listen_Socket_Port :
                       Socket_Defs.Socket_Port;
                    The_Remote_Server_Host_Name : Socket_Defs.Host_Name;
                begin

                    -- Extract

                    Service_Socket_Id :=
                       Join_Server (The_Remote_Server_Host_Name,
                                    The_Remote_Server_Listen_Socket_Port);
                    if Service_Socket_Id < 0 then
                        raise Socket_Defs.Join_Server_Error;
                    end if;  
                    Send_String (Service_Socket_Id, The_Msg,
                                 Socket_Defs.Msg_Length,
                                 Number_Of_Caracteres_Sent);
                    Close_Socket (Service_Socket_Id);

                end;
            else
                null;
            end select;
        end loop;

    end Behavior_Client_Task;


end Behavior_Tasks;