with Tftp_Utilities, Io, Transport_Defs, Transport_Name, Transport;
procedure Put (To_Host : in String;
               Local_Pathname : in String;
               Remote_Pathname : in String := "";
               Mode : in String := "TEXT") is
    Remote_Host : Transport_Defs.Host_Id (1 .. 4) :=
       Transport_Name.Host_To_Host_Id (To_Host);
    Remote_Socket : Transport_Defs.Socket_Id (1 .. 2) := (0, 69);
    Connection : Transport.Connection_Id;
    Status : Transport_Defs.Status_Code;
    Lmode : String (1 .. Mode'Length) := Mode;
    Cmode : Tftp_Utilities.Transfer_Mode;
    Moderr : Boolean := False;
begin
    for I in Lmode'First .. Lmode'Last loop
        if Lmode (I) in 'a' .. 'z' then
            Lmode (I) := Character'Val
                            (Character'Pos (Lmode (I)) - Character'Pos (' '));
        end if;
    end loop;
    if Lmode = "TEXT" then
        Cmode := Tftp_Utilities.Text;
    elsif Lmode = "MAIL" then
        Cmode := Tftp_Utilities.Mail;
    elsif Lmode = "BINARY" then
        Cmode := Tftp_Utilities.Binary;
    else
        Moderr := True;
    end if;
    if not Moderr then
        Transport.Open (Connection, Status, "UDP/IP");
        if Transport_Defs."=" (Transport_Defs.Ok, Status) then
            Transport.Connect (Connection, Status, Remote_Host,
                               Remote_Socket, 5.0);
            if Transport_Defs."=" (Transport_Defs.Ok, Status) then
                if Remote_Pathname = "" then
                    Tftp_Utilities.Send_A_File
                       (Local_Pathname, Local_Pathname, Tftp_Utilities.Text,
                        Tftp_Utilities.Client, Connection);
                else
                    Tftp_Utilities.Send_A_File
                       (Local_Pathname, Remote_Pathname, Tftp_Utilities.Text,
                        Tftp_Utilities.Client, Connection);
                end if;
                Transport.Disconnect (Connection);
                Transport.Close (Connection);
            end if;
        end if;
        Io.Put ("Transfer of " & Local_Pathname & " to !!" & To_Host);
        if Remote_Pathname = "" then
            Io.Put (Local_Pathname);
        else
            Io.Put (Remote_Pathname);
        end if;
        Io.Put_Line (" is complete.");
    else
        Io.Put_Line ("Illegal transfer mode => " & Mode);
    end if;
exception
    when Transport_Name.Undefined =>
        Io.Put_Line ("Host " & To_Host & " is unknown to the system.");
    when Tftp_Utilities.Timeout =>
        Io.Put_Line ("Transfer timed out.");
        Transport.Disconnect (Connection);
        Transport.Close (Connection);
    when others =>
        raise;
end Put;