Ada编程-套接字阻止行为

问题描述 投票:0回答:2

请注意,这个问题特定地针对Ada语言和Ada的“ g-socket” API

我已经在本地打开了一个Socket,正在监听传入的连接。接受连接,通过读取和写入连接到远程套接字的Stream对象,我可以在连接上建立一些连贯的数据传输。]

问题:

当流附加到TCP套接字时,对通用流'Write过程的每次调用都会导致立即发送数据包吗?

示例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);

示例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)
  );

示例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);

示例A和C导致Wireshark检测到格式错误的数据包,但是示例B创建了精心设计的数据包,没有任何问题。

此行为似乎是确定性的,但是我找不到有关'Write->流->关于如何以及何时分派数据包的套接字安排的任何连贯的文档。

[请注意,这个问题专门针对Ada语言和Ada的“ g-socket” API,我已经在本地打开了一个Socket,正在监听传入的连接。接受连接...

sockets tcp stream ada
2个回答
1
投票

根据this link,TCP流Write的基础代码应如下。如您所见,有一个循环尝试发送数据,直到所有内容都传递到Send_Socket中为止。所以对我来说,一切都取决于C_Sendto实现,而fwhici本身称为OS原语


1
投票

’Write’Read的默认行为在ARM13.13.2(8.2)中定义。

© www.soinside.com 2019 - 2024. All rights reserved.