text stringlengths 0 234 |
|---|
use type Ada.Streams.Stream_Element_Offset; |
type Socket_Connection is record |
Socket : GNAT.Sockets.Socket_Type; |
Addr : GNAT.Sockets.Sock_Addr_Type; |
Job : Torrent.Downloaders.Downloader_Access; |
end record; |
package Socket_Connection_Vectors is new Ada.Containers.Vectors |
(Positive, Socket_Connection); |
type Planned_Connection is record |
Time : Ada.Calendar.Time; |
Addr : GNAT.Sockets.Sock_Addr_Type; |
Job : Torrent.Downloaders.Downloader_Access; |
end record; |
function Less (Left, Right : Planned_Connection) return Boolean; |
package Planned_Connection_Sets is new Ada.Containers.Ordered_Sets |
(Element_Type => Planned_Connection, |
"<" => Less); |
type Accepted_Connection is record |
Socket : GNAT.Sockets.Socket_Type; |
Address : GNAT.Sockets.Sock_Addr_Type; |
Data : Torrent.Handshakes.Handshake_Image; |
Last : Ada.Streams.Stream_Element_Count; |
Done : Boolean; |
Session : Torrent.Connections.Connection_Access; |
end record; |
package Accepted_Connection_Vectors is new Ada.Containers.Vectors |
(Positive, Accepted_Connection); |
procedure Accept_Connection |
(Server : GNAT.Sockets.Socket_Type; |
Accepted : in out Accepted_Connection_Vectors.Vector); |
procedure Read_Handshake (Item : in out Accepted_Connection); |
function Hash (Item : Torrent.Connections.Connection_Access) |
return Ada.Containers.Hash_Type; |
package Connection_Sets is new Ada.Containers.Hashed_Sets |
(Element_Type => Torrent.Connections.Connection_Access, |
Hash => Hash, |
Equivalent_Elements => Torrent.Connections."=", |
"=" => Torrent.Connections."="); |
function "+" |
(Value : Torrent.Connections.Connection_Access) |
return System.Storage_Elements.Integer_Address; |
--------- |
-- "+" -- |
--------- |
function "+" |
(Value : Torrent.Connections.Connection_Access) |
return System.Storage_Elements.Integer_Address |
is |
package Conv is new System.Address_To_Access_Conversions |
(Object => Torrent.Connections.Connection'Class); |
begin |
return System.Storage_Elements.To_Integer |
(Conv.To_Address (Conv.Object_Pointer (Value))); |
end "+"; |
----------------------- |
-- Accept_Connection -- |
----------------------- |
procedure Accept_Connection |
(Server : GNAT.Sockets.Socket_Type; |
Accepted : in out Accepted_Connection_Vectors.Vector) |
is |
Address : GNAT.Sockets.Sock_Addr_Type; |
Socket : GNAT.Sockets.Socket_Type; |
begin |
GNAT.Sockets.Accept_Socket (Server, Socket, Address); |
pragma Debug |
(Torrent.Logs.Enabled, |
Torrent.Logs.Print ("Accepted: " & GNAT.Sockets.Image (Address))); |
GNAT.Sockets.Set_Socket_Option |
(Socket => Socket, |
Level => GNAT.Sockets.Socket_Level, |
Option => (GNAT.Sockets.Receive_Timeout, 0.0)); |
Accepted.Append |
((Socket, |
Last => 0, |
Done => False, |
Address => Address, |
others => <>)); |
end Accept_Connection; |
---------- |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.