TCP Handling
SomeIpCloseEstablishedTCPConnection
CAPL 函数 >> 以太网 >> SOME/IP IL >> SomeIpCloseEstablishedTCPConnection
函数功能
关闭一个或多个数据库中定义的 TCP 连接。
语法
capl
dword SomeIpCloseEstablishedTCPConnection(); // 形式 1
dword SomeIpCloseEstablishedTCPConnection(dword aepHandle); // 形式 2
dword SomeIpCloseEstablishedTCPConnection(dword aepHandle, dword remoteIPv4Address); // 形式 3
dword SomeIpCloseEstablishedTCPConnection(dword aepHandle, dword remoteIPv4Address, dword remotePort); // 形式 4
dword SomeIpCloseEstablishedTCPConnection(dword aepHandle, byte remoteIPv6Address[]); // 形式 5
long SomeIpCloseEstablishedTCPConnection(dword aepHandle, byte remoteIPv6Address[], dword remotePort); // 形式 6
long SomeIpCloseEstablishedTCPConnection(dword aepHandle, IP_Endpoint remoteIPEndpoint); // 形式 7
形式说明
- 形式 1:关闭本节点(作为 TCP 客户端)的所有 TCP 连接。
- 形式 2:关闭 TCP 客户端的所有 TCP 连接。
- 形式 3/5:关闭 TCP 客户端与特定 TCP 服务器的所有 TCP 连接。
- 形式 4/6:关闭 TCP 客户端与特定 TCP 服务器的 TCP 连接。
TCP 连接可通过
SomeIpEstablishTCPConnection函数建立。
参数说明
- aepHandle:发起连接的源应用端点,必须在数据库中定义。
- remotePort:可发送和接收消息的端口。
- remoteIPv4Address :需关闭连接的 IPv4 地址,可通过
IPGetAddressAsNumber函数转换。 - remoteIPv6Address :需关闭连接的 IPv6 地址,可通过
IpGetAddressAsArray函数转换。 - remoteIPEndpoint :
IP_Endpoint类型对象,包含远程端点的地址和端口。
返回值
- 0:函数执行成功。
- >0:错误代码。
可用性
| 版本 | 支持形式 | 限制范围 | 测量配置 | 仿真/测试配置 |
|---|---|---|---|---|
| 11.0 SP3 | 形式 1-6 | 以太网 | --- | • |
| 12.0 SP2 | 形式 7 | 以太网 | --- | • |
示例
capl
variables
{
dword aep; // 应用端点句柄
}
on start
{
// 句柄需关联数据库中有效的应用端点
aep = SomeIpOpenLocalApplicationEndpoint(IP_Endpoint(TCP:192.168.1.1:40000));
}
on key 'o'
{
// 建立到特定端点的连接
if (SomeIpEstablishTCPConnection(aep, IP_Endpoint(TCP:192.168.1.2:50000)) != 0)
{
write("连接未建立");
}
}
on key 'c'
{
// 关闭节点上下文中的所有连接
if (SomeIpCloseEstablishedTCPConnection() == 0)
{
write("连接已关闭");
}
}
SomeIpEstablishTCPConnection
CAPL 函数 >> 以太网 >> SOME/IP IL >> SomeIpEstablishTCPConnection
函数功能
建立一个或多个数据库中定义的 TCP 连接。
语法
capl
dword SomeIpEstablishTCPConnection(); // 形式 1
dword SomeIpEstablishTCPConnection(dword aepHandle); // 形式 2
dword SomeIpEstablishTCPConnection(dword aepHandle, dword remoteIPv4Address); // 形式 3
dword SomeIpEstablishTCPConnection(dword aepHandle, dword remoteIPv4Address, dword remotePort); // 形式 4
dword SomeIpEstablishTCPConnection(dword aepHandle, byte remoteIPv6Address[]); // 形式 5
long SomeIpEstablishTCPConnection(dword aepHandle, byte remoteIPv6Address[], dword remotePort); // 形式 6
long SomeIpEstablishTCPConnection(dword aepHandle, IP_Endpoint remoteIPEndpoint); // 形式 7
形式说明
- 形式 1:建立本节点(作为 TCP 客户端)的所有 TCP 连接。
- 形式 2:建立 TCP 客户端的所有 TCP 连接。
- 形式 3/5:建立 TCP 客户端与特定 TCP 服务器的所有 TCP 连接。
- 形式 4/6:建立 TCP 客户端与特定 TCP 服务器的 TCP 连接。
TCP 连接可通过
SomeIpCloseEstablishedTCPConnection函数关闭。
参数说明
- aepHandle:发起连接的源应用端点,必须在数据库中定义。
- remotePort:可发送和接收消息的端口。
- remoteIPv4Address :需建立连接的 IPv4 地址,可通过
IPGetAddressAsNumber函数转换。 - remoteIPv6Address :需建立连接的 IPv6 地址,可通过
IpGetAddressAsArray函数转换。 - remoteIPEndpoint :
IP_Endpoint类型对象,包含远程端点的地址和端口。
返回值
- 0:函数执行成功。
- >0:错误代码。
可用性
| 版本 | 支持形式 | 限制范围 | 测量配置 | 仿真/测试配置 |
|---|---|---|---|---|
| 11.0 SP3 | 形式 1-6 | 以太网 | --- | • |
| 12.0 SP2 | 形式 7 | 以太网 | --- | • |
示例
capl
variables
{
dword aep; // 应用端点句柄
}
on start
{
// 句柄需关联数据库中有效的应用端点
aep = SomeIpOpenLocalApplicationEndpoint(IP_Endpoint(TCP:192.168.1.1:40000));
}
on key 'o'
{
// 建立到特定端点的连接
if (SomeIpEstablishTCPConnection(aep, IP_Endpoint(TCP:192.168.1.2:50000)) != 0)
{
write("连接未建立");
}
}
on key 'c'
{
// 关闭节点上下文中的所有连接
if (SomeIpCloseEstablishedTCPConnection() == 0)
{
write("连接已关闭");
}
}
SomeIpTCPListen
CAPL 函数 >> 以太网 >> SOME/IP IL >> SomeIpTCPListen
函数功能
监听此 TCP 应用端点。
语法
capl
long SomeIpTCPListen(dword aepHandle)
参数说明
- aepHandle:应用端点。
返回值
- 0:函数执行成功。
可用性
| 版本 | 限制范围 | 测量配置 | 仿真/测试配置 |
|---|---|---|---|
| 11.0 SP3 | 以太网 | --- | • |