一个用于 TCP 通信的类,继承自 AComm 并符合 NSStreamDelegate 协议。
更多...
#include <TcpComm.h>
一个用于 TCP 通信的类,继承自 AComm 并符合 NSStreamDelegate 协议。
◆ close
关闭与 TCP 服务器的连接。
重载 AComm .
◆ descriptorUseIp:descriptorUsePort:
- (NSString *) descriptorUseIp: |
|
(NSString *) | ip |
descriptorUsePort: |
|
(NSString *) | port |
使用指定的 IP 和端口返回描述符字符串。
- 参数
-
ip | 用于描述符的 IP 地址。 |
port | 用于描述符的端口。 |
- 返回
- 一个描述符字符串。
◆ initWithIPAddress:port:
- (instancetype) initWithIPAddress: |
|
(NSString *) | ipAddress |
port: |
|
(NSUInteger) | port |
使用给定的 IP 地址和端口初始化一个新实例。
- 参数
-
ipAddress | TCP 服务器的 IP 地址。 |
port | TCP 服务器的端口号。 |
- 返回
- 一个初始化的 TcpComm 实例,如果无法创建对象,则返回 nil。
◆ NS_ENUM
- (typedef) NS_ENUM |
|
(NSInteger) | |
|
|
(DescriptorPortType) | |
描述符端口的类型。
此枚举定义了系统中使用的描述符端口类型。
示例用法:
DescriptorPortType portType = DescriptorPortTypeData;
switch (portType) {
case DescriptorPortTypeData:
break;
case DescriptorPortTypeMGMT:
break;
case DescriptorPortTypeStatus:
break;
}
◆ open
打开与 TCP 服务器的连接。
重载 AComm .
◆ read
从 TCP 服务器读取数据。
- 返回
- 从服务器读取的数据。
重载 AComm .
◆ sendPrintFile:fileName:
- (void) sendPrintFile: |
|
(NSString *) | ipAddress |
fileName: |
|
(NSString *) | fileName |
将打印文件发送到指定的 IP 地址。
- 参数
-
ipAddress | 印表机的 IP 地址。 |
fileName | 要打印的文件名。 |
◆ sendPrintString:data:
- (void) sendPrintString: |
|
(NSString *) | ipAddress |
data: |
|
(NSData *) | data |
使用 TSPL 或 PGL 将打印字符串发送到指定的 IP 地址。
- 参数
-
ipAddress | 印表机的 IP 地址。 |
data | 要打印的数据。 |
◆ validateDescriptor:withPortType:
- (NSString *) validateDescriptor: |
|
(NSString *) | descriptorHint |
withPortType: |
|
(DescriptorPortType) | portTypeHint |
使用指定的提示和端口类型验证描述符。
- 参数
-
descriptorHint | 描述符的提示。 |
portTypeHint | 要验证的端口类型。 |
- 返回
- 验证后的描述符字符串。
◆ write:
- (void) write: |
|
(NSData *) | text |
|
将数据写入 TCP 服务器。
- 参数
-
重载 AComm .
◆ writeAndWaitForResponse:responseStartTimeOut:responseEndTimeOut:completionToken:
- (NSData *) writeAndWaitForResponse: |
|
(NSData *) | text |
responseStartTimeOut: |
|
(NSTimeInterval) | responseStartTimeOut |
responseEndTimeOut: |
|
(NSTimeInterval) | responseEndTimeOut |
completionToken: |
|
(NSString *) | completionToken |
将数据写入 TCP 服务器并等待响应。
- 参数
-
text | 要写入服务器的数据。 |
responseStartTimeOut | 响应开始的超时间隔。 |
responseEndTimeOut | 响应结束的超时间隔。 |
completionToken | 表示响应完成的令牌。 |
- 返回
- 从服务器接收到的响应数据。
重载 AComm .
◆ writeAndWaitForResponseJson:responseStartTimeOut:responseEndTimeOut:completionToken:
- (NSData *) writeAndWaitForResponseJson: |
|
(NSData *) | text |
responseStartTimeOut: |
|
(NSTimeInterval) | responseStartTimeOut |
responseEndTimeOut: |
|
(NSTimeInterval) | responseEndTimeOut |
completionToken: |
|
(NSString *) | completionToken |
将 JSON 数据写入 TCP 服务器并等待响应。
- 参数
-
text | 要写入服务器的 JSON 数据。 |
responseStartTimeOut | 响应开始的超时间隔。 |
responseEndTimeOut | 响应结束的超时间隔。 |
completionToken | 表示响应完成的令牌。 |
- 返回
- 从服务器接收到的响应数据。
◆ writePrinterFile:
- (void) writePrinterFile: |
|
(NSString *) | fileName |
|
◆ connected
该类的文档由以下文件生成:
- /Users/realbuber/Documents/Project/sdk_json_Objective-C/AutoIdSDK/Comm/TcpComm.h