Use task-aware I/O.

Keep synchronous Ada call semantics, or group bounded scoped operations when one task must coordinate concurrent progress.

STEP 08

Keep synchronous call semantics.

Flyology I/O packages provide normal procedure and function calls in both lanes. The example uses Flyology.IO.Timers.Sleep_For and the Flyology.IO.Sockets.Receive and Flyology.IO.Files.Read_At overload families. If a lightweight call would block, only the lightweight task waits, so the event-loop thread remains available. If a native call blocks, it blocks only its own OS thread.

task-aware I/O
Flyology.IO.Timers.Sleep_For (0.050);

Flyology.IO.Sockets.Receive
  (Socket, Buffer, Last, Timeout => 1.0);

Flyology.IO.Files.Read_At
  (File, Offset => 0, Item => Buffer, Last => Last);

Choose raw or managed client ownership

Use the public raw socket layer for a simple synchronous client or an adapter that accepts a Socket_Type. It also supports datagrams, Unix sockets, and custom socket configuration. Create the socket for the endpoint family, call the task-aware socket Connect, and close that owner when the protocol session ends. Managed connections do not replace or deprecate this layer.

Use Flyology.IO.Connections when a protocol adapter requires connection ownership, cancellation, in-place TLS replacement, or the set-independent driver capability. Its synchronous Connect procedure reserves admission, creates the Internet stream socket, connects it, and transfers sole ownership to the caller's Connection. One deadline covers all three stages. Use this procedure when protocol setup can start after one task-aware connection call.

managed connection for a composable protocol adapter
package Connections renames Flyology.IO.Connections;

Manager : aliased Connections.Server (Capacity => 1);
Client  : aliased Connections.Connection (Manager'Access);

Connections.Connect
  (Manager, Server_Endpoint, Client, Timeout => 5.0);

--  Construct the protocol transport over Client'Access. Its operations can
--  drive Flyology.IO.Connections.Drivers.Capability in a completion set.

Declare the manager before the connection so the manager outlives every admitted owner. A lightweight caller suspends during admission or socket readiness. A native caller blocks only its pthread. On timeout, cancellation, shutdown, socket failure, or failed adoption, Connect closes the temporary socket and releases the permit. Normal Connection finalization closes the adopted socket and releases that permit.

Use the operation-producing Connect overload when connection construction must join a Completion_Set. Its Connect_Operation owns the temporary socket and admission permit. Typed Finish transfers both resources to a closed connection.

managed connection as a scoped operation
declare
   Set : aliased Flyology.Operations.Completion_Set (2);
   Attempt : Connections.Connect_Operation :=
     Connections.Connect
       (Set'Access,
        Manager'Access,
        Server_Endpoint,
        Timeout => 5.0);
begin
   Flyology.Operations.Wait_All (Set);
   Connections.Finish (Attempt, Client);
end;

The parent and its hidden raw-socket child use two set slots while the kernel connects. Admission waiting and a retained result use one slot. Cancellation or scope exit drains the child before cleanup. The operation does not borrow the target connection while it is pending.

Use Take instead when the application already owns a connected or specially configured socket. After either construction path, a runtime-selected protocol adapter can store one Connections.Drivers.Capability. The outer protocol operation still owns the only completion-set slot.

When one owner must coordinate concurrent progress, continue with the scoped operations chapter.

Connect to a pathname Unix socket

Use a Unix_Path for a pathname socket instead of the Internet Endpoint type. Unix_Pathname rejects an empty path, an embedded NUL byte, or a value longer than the host limit. Flyology passes the accepted bytes to the operating system without encoding conversion. Maximum_Unix_Path_Length reports the maximum pathname byte count, excluding the terminating NUL byte.

Create an owned Socket_Type with Create_Unix_Stream_Socket, then call the pathname overload of Connect. The call can block a native task's OS thread, but a lightweight caller suspends while its event loop waits for readiness.

The timeout covers the complete connection attempt. A readable interrupt descriptor raises Operation_Interrupted. Host socket failures raise Socket_Error. Once created, the caller retains closing ownership and must call Close_Socket after connection success or failure.

connect to the Docker Unix socket
with Flyology.IO.Sockets;

procedure Use_Docker_Socket is
   package Sockets renames Flyology.IO.Sockets;
   Docker : constant Sockets.Unix_Path :=
     Sockets.Unix_Pathname ("/var/run/docker.sock");
   Socket : Sockets.Socket_Type;
begin
   Sockets.Create_Unix_Stream_Socket (Socket);
   begin
      Sockets.Connect (Socket, Docker, Timeout => 2.0);
      --  Use Socket for the Docker HTTP exchange here.
   exception
      when others =>
         begin
            Sockets.Close_Socket (Socket);
         exception
            when Sockets.Socket_Error => null;
         end;
         raise;
   end;
   Sockets.Close_Socket (Socket);
end Use_Docker_Socket;

For a local server or a deterministic test, call the pathname overload of Bind_Socket, then Listen_Socket and the address-free Accept_Connection overload. Binding creates a filesystem entry under the process umask and directory permissions. Flyology does not unlink an existing path before bind and does not remove the entry when the listener closes. The application owns stale-entry checks, safe replacement, and final unlink.

For relative waits, monotonic deadlines, adjustable wall-clock targets, and backward-clock detection, continue with the timers guide.

To observe files and directories through bounded, task-aware registrations, continue with the file-watching guide.

To move positional regular-file regions to connected stream sockets with native sendfile, Linux lightweight SEND_ZC, and completion-driven fallbacks, continue with the file-transfer guide.

Use the ownership-aware connection packages when descriptor lifetime, cancellation, and close races matter. Raw descriptor waits deliberately leave lifetime serialization to the caller.

Browse the generated API reference