Please note that this question is specifically aimed at the Ada language and Ada's "g-socket" API
I have opened a Socket locally and am listening for incoming connections. Connections are accepted and I am able to establish somewhat coherent data transfer over the connection by reading from and writing to a Stream object attached to the remote socket.
Question:
When a Stream is attached to a TCP Socket, does each call to a generalised stream 'Write
procedure cause a packet to be sent immediately?
Example A:
-- two separate `'Write` calls always seems to generate two packets of 1 byte each
U8'Write (Comms, Number_Of_Security_Types);
U8'Write (Comms, Security_Type_None);
Example B:
-- One `'Write` call that happens to send the same data formatted as a 16 bit value is sent as a single packet.
U16'Write (Comms,
(U16 (Number_Of_Security_Types) * 16#100#) +
U16 (Security_Type_None)
);
Example C:
-- This is a complex record with a further record nested within it.
-- its `'Write` callback is implemented as a series of many sequential `Integer'Write` calls...
Server_Init'Write (Comms, Server_Init_Rec);
Examples A and C cause malformed packets to be detected by Wireshark, but Example B creates a well crafted packet with no issues.
This behaviour seems deterministic but I cannot find any coherent documentation regarding the 'Write
--> Stream --> Socket arrangement with regard to how and when packets are dispatched.