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

⟦17ad51f66⟧ Ada Source

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

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 Byte_Defs;
with Net_Info;
with Text_Io;
with Transport;
with Transport_Defs;
with Utils;
package body Test_Transport_Level is


    function "=" (L, R : Transport_Defs.Status_Code) return Boolean
        renames Transport_Defs."=";



    Connection_Retry_Interval : constant Duration := 60.0;
    type Retries is range 1 .. 3;




    procedure Start_Client is

        Status : Transport_Defs.Status_Code := Transport_Defs.Ok;
        Connection : Transport.Connection_Id;
        Message : constant Byte_Defs.Byte_String :=
           Utils.String_To_Byte_String (Net_Info.Test_String);
        Bytes_Transmitted : Natural;
        Bytes_Received : Natural;
        Open_Attempt : Integer := 1;
        Rec_Buf : Byte_Defs.Byte_String (1 .. 1024);

    begin

        for Again in 1 .. 3 loop

            Open_Loop:
                for I in Retries loop

                    if not Transport.Is_Open (Connection => Connection) then

                        Transport.Open  
                           (Connection => Connection,
                            Status => Status,
                            Network => Net_Info.Net_Name,
                            Local_Socket => Transport_Defs.Null_Socket_Id);

                        if Status /= Transport_Defs.Ok then
                            Text_Io.Put_Line
                               ("*** Client Socket Open Failed. Error Code: " &
                                Transport_Defs.Image (Status));

                            if Status = Transport_Defs.Socket_In_Use then
                                Text_Io.Put_Line ("--- Will retry.");
                                delay Connection_Retry_Interval;
                            else
                                return;
                            end if;

                        else
                            Text_Io.Put_Line ("+++ Client Socket Open");
                            exit Open_Loop;
                        end if;
                    end if;


                end loop Open_Loop;

            if not Transport.Is_Connected (Connection => Connection) then

                Transport.Connect (Connection => Connection,
                                   Status => Status,
--                               Remote_Host   => Net_Info.R1000_Address,
                                   Remote_Host => Net_Info.Sparc_Address,
--                               Remote_Socket => Net_Info.R1000_Socket,
                                   Remote_Socket => Net_Info.Sparc_Socket,
                                   Max_Wait => Duration'Last);

                if Status /= Transport_Defs.Ok then
                    Text_Io.Put_Line
                       ("*** Client Connect Failed. Error Code: " &
                        Transport_Defs.Image (Status));
                    return;

                else
                    Text_Io.Put_Line ("+++ Client Connected");
                end if;

            else

                Text_Io.Put_Line ("--* Client Socket Already Connected");

            end if;


            Data_Transfer_Loop:
                for I in 1 .. 10 loop

                    Bytes_Transmitted := 0;

                    Transport.Transmit (Connection => Connection,
                                        Status => Status,
                                        Data => Message,
                                        Count => Bytes_Transmitted,
                                        Max_Wait => Duration'Last,
                                        More => False);

                    if Status /= Transport_Defs.Ok then

                        Text_Io.Put_Line
                           ("*** Client Transmission Failed. Error Code: " &
                            Transport_Defs.Image (Status));

                        exit Data_Transfer_Loop;

                    elsif Bytes_Transmitted /= Message'Length then

                        Text_Io.Put_Line
                           ("--* Client Transmission Incomplete.");

                    else

                        Text_Io.Put_Line ("+++ Client Tranmission Completed.");

                    end if;


                    Transport.Receive (Connection => Connection,
                                       Status => Status,
                                       Data => Rec_Buf,
                                       Count => Bytes_Received,
                                       Max_Wait => Duration'Last);

                    if Status /= Transport_Defs.Ok then

                        Text_Io.Put_Line
                           ("*** Client Receive Failed. Error Code: " &
                            Transport_Defs.Image (Status));

                        exit Data_Transfer_Loop;

                    else

                        Text_Io.Put_Line ("+++ Client Received: " &
                                          Utils.Byte_String_To_String
                                             (Rec_Buf (1 .. Bytes_Received)));

                    end if;


                end loop Data_Transfer_Loop;

            if Transport.Is_Connected (Connection => Connection) then
                Transport.Disconnect (Connection => Connection);
            end if;

            if Transport.Is_Open (Connection => Connection) then
                Transport.Close (Connection => Connection);
            end if;

            delay 5.0;

        end loop;
    end Start_Client;




    procedure Start_Server is

        Status : Transport_Defs.Status_Code := Transport_Defs.Ok;
        Connection : Transport.Connection_Id;
        Bytes_Transmitted : Natural;
        Bytes_Received : Natural;
        Rec_Buf : Byte_Defs.Byte_String (1 .. 1024);


    begin
        Accept_Loop:
            loop

                if not Transport.Is_Open (Connection => Connection) then

                    Transport.Open (Connection => Connection,
                                    Status => Status,
                                    Network => Net_Info.Net_Name,
                                    Local_Socket => Net_Info.R1000_Socket);

                    if Status /= Transport_Defs.Ok then
                        Text_Io.Put_Line
                           ("*** Server Socket Open Failed. Error Code: " &
                            Transport_Defs.Image (Status));
                        return;

                    else
                        Text_Io.Put_Line ("+++ Server Socket Open");
                    end if;

                else
                    Text_Io.Put_Line
                       ("--* Server Socket Already Open, reusing socket");
                end if;


                if not Transport.Is_Connected (Connection => Connection) then

                    Transport.Connect (Connection => Connection,
                                       Status => Status,
                                       Max_Wait => Duration'Last);

                    if Status /= Transport_Defs.Ok then
                        Text_Io.Put_Line
                           ("*** Server Connect Failed. Error Code: " &
                            Transport_Defs.Image (Status));
                        return;

                    else
                        Text_Io.Put_Line ("+++ Server Connected");
                    end if;

                else

                    Text_Io.Put_Line ("--* Server Socket Already Connected");

                end if;

                Data_Reception_Loop:
                    loop

                        Bytes_Received := 0;

                        Transport.Receive (Connection => Connection,
                                           Status => Status,
                                           Data => Rec_Buf,
                                           Count => Bytes_Received,
                                           Max_Wait => Duration'Last);

                        if Status /= Transport_Defs.Ok then

                            Text_Io.Put_Line
                               ("*** Server Receive Failed. Error Code: " &
                                Transport_Defs.Image (Status));

                            exit Data_Reception_Loop;

                        else

                            Text_Io.Put_Line
                               ("+++ Server Received: " &
                                Utils.Byte_String_To_String
                                   (Rec_Buf (1 .. Bytes_Received)));

                        end if;


                        if Bytes_Received > 0 then

                            Bytes_Transmitted := 0;

                            Transport.Transmit
                               (Connection => Connection,
                                Status => Status,
                                Data => Rec_Buf (1 .. Bytes_Received),
                                Count => Bytes_Transmitted,
                                Max_Wait => Duration'Last,
                                More => False);

                            if Status /= Transport_Defs.Ok then

                                Text_Io.Put_Line
                                   ("*** Server Transmission Failed. Error Code: " &
                                    Transport_Defs.Image (Status));

                                exit Data_Reception_Loop;

                            elsif Bytes_Transmitted /= Bytes_Received then

                                Text_Io.Put_Line
                                   ("--* Server Transmission Incomplete.");

                            else

                                Text_Io.Put_Line
                                   ("+++ Server Tranmission Completed.");

                            end if;

                        end if;

                    end loop Data_Reception_Loop;

                if Transport.Is_Connected (Connection => Connection) then
                    Transport.Disconnect (Connection => Connection);
                end if;

                if Transport.Is_Open (Connection => Connection) then
                    Transport.Close (Connection => Connection);
                end if;

            end loop Accept_Loop;

    end Start_Server;


end Test_Transport_Level;

E3 Meta Data

    nblk1=b
    nid=0
    hdr6=16
        [0x00] rec0=28 rec1=00 rec2=01 rec3=094
        [0x01] rec0=16 rec1=00 rec2=02 rec3=02c
        [0x02] rec0=18 rec1=00 rec2=03 rec3=048
        [0x03] rec0=1e rec1=00 rec2=04 rec3=01e
        [0x04] rec0=1c rec1=00 rec2=05 rec3=058
        [0x05] rec0=26 rec1=00 rec2=06 rec3=006
        [0x06] rec0=19 rec1=00 rec2=07 rec3=014
        [0x07] rec0=1b rec1=00 rec2=08 rec3=046
        [0x08] rec0=1b rec1=00 rec2=09 rec3=05e
        [0x09] rec0=17 rec1=00 rec2=0a rec3=076
        [0x0a] rec0=16 rec1=00 rec2=0b rec3=000
    tail 0x21759946087a05ca61be4 0x42a00088462060003