第二十四章 TCP 客户端 服务器通信 - 当前 TCP 设备
当前 TCP 设备
可以使用 %SYSTEM.TCPDevice方法返回当前 TCP 设备的 IP 地址和端口号。可以使用 方法列出这些方法,如下所示:
DO $SYSTEM.TCPDevice.Help()
可以通过在 中指定方法名称来显示有关特定方法的信息,如以下示例所示:
DO $SYSTEM.TCPDevice.Help("LocalAddr")
IMP>DO $SYSTEM.TCPDevice.Help("LocalAddr")
method:class的描述 LocalAddr:%SYSTEM.TCPDevice
LocalAddr(Format:%Integer=0)
Get local IP address of current TCP device.<br>
<br>
<b>Parameters:</b> <br>
<b>Format</b> - The format of address to be returned. If this argument is omitted the default value is 0. The value could be:<br>
<ul><li>0: in text format, 'dotted' decimal string for IPV4, colon-hex address string for IPV6.</li>
<li>1: in binary format, 4 character length for IPV4, 16 characters for IPV6.</li></ul>
<b>Return:</b> <br>
Returns the local IP address associated with the TCP device. It could be in binary or text format depends on the <b>Format</b> parameter.
For binary format the IP address is in Network order.<br>
If the current device ($IO) is not a TCP device, it gets <FUNCTION> error.<br>
If the TCP device is in 'listening' state, the IP address would be all zeros (INADDR_ANY).<br>
.jpg)



