一個用於 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
此類別(class) 文件是由下列檔案中產生:
- /Users/realbuber/Documents/Project/sdk_json_Objective-C_IOS/sdk_json_Objective-C_IOS/Comm/TcpComm.h