UniPRT SDK v1.0.0.0
 
載入中...
搜尋中...
無符合項目
TcpComm 類別 參考文件

一個用於 TCP 通信的類,繼承自 AComm 並符合 NSStreamDelegate 協議。 更多...

#include <TcpComm.h>

類別TcpComm的繼承圖:
AComm <IComm>

實體方法

(instancetype) - initWithIPAddress:port:
 使用給定的 IP 地址和端口初始化一個新實例。
 
(void) - open
 打開與 TCP 服務器的連接。
 
(void) - close
 關閉與 TCP 服務器的連接。
 
(void) - write:
 將數據寫入 TCP 服務器。
 
(NSData *) - read
 從 TCP 服務器讀取數據。
 
(NSString *) - descriptorUseIp:descriptorUsePort:
 使用指定的 IP 和端口返回描述符字符串。
 
(NSData *) - writeAndWaitForResponse:responseStartTimeOut:responseEndTimeOut:completionToken:
 將數據寫入 TCP 服務器並等待響應。
 
(NSData *) - writeAndWaitForResponseJson:responseStartTimeOut:responseEndTimeOut:completionToken:
 將 JSON 數據寫入 TCP 服務器並等待響應。
 
(typedef) - NS_ENUM
 描述符端口的類型。
 
(NSString *) - validateDescriptor:withPortType:
 使用指定的提示和端口類型驗證描述符。
 
(void) - sendPrintFile:fileName:
 將打印文件發送到指定的 IP 地址。
 
(void) - sendPrintString:data:
 使用 TSPLPGL 將打印字符串發送到指定的 IP 地址。
 
(void) - writePrinterFile:
 將文件寫入打印機。
 
- 實體方法 繼承自 AComm
(void) - readToBinaryWriter:
 將數據讀入二進制寫入器(輸出流)。
 
(void) - waitForDataWithTimeout:
 等待數據在指定的超時內可用。
 
(void) - writeFromBinaryReader:
 將數據從二進制讀取器(輸入流)寫入通信接口。
 
(void) - writeAndWaitForResponseToBinaryWriter:fromBinaryReader:responseStartTimeout:responseEndTimeout:completionToken:
 將數據寫入通信接口並等待響應,使用二進制流。
 

屬性(properties)

BOOL connected
 指示連接是否已建立的標誌。
 
- 屬性(properties) 繼承自 AComm
int maxPacketSize
 通信的最大數據包大小。
 
NSString * descriptor
 通信接口的描述符。
 
int bytesAvailable
 可讀取的字節數。
 
BOOL isConnected
 指示連接是否建立的標誌。
 
- 屬性(properties) 繼承自 <IComm>
NSString * descriptor
 通信接口的描述符。
 
int bytesAvailable
 可讀取的字節數。
 
BOOL isConnected
 指示連接是否已建立的標誌。
 

詳細描述

一個用於 TCP 通信的類,繼承自 AComm 並符合 NSStreamDelegate 協議。

方法文件

◆ close

- (void) 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 地址和端口初始化一個新實例。

參數
ipAddressTCP 服務器的 IP 地址。
portTCP 服務器的端口號。
傳回值
一個初始化的 TcpComm 實例,如果無法創建對象,則返回 nil。

◆ NS_ENUM

- (typedef) NS_ENUM (NSInteger)
(DescriptorPortType)  

描述符端口的類型。

此枚舉定義了系統中使用的描述符端口類型。

示例用法:

DescriptorPortType portType = DescriptorPortTypeData;
switch (portType) {
case DescriptorPortTypeData:
// 處理數據端口
break;
case DescriptorPortTypeMGMT:
// 處理管理端口
break;
case DescriptorPortTypeStatus:
// 處理狀態端口
break;
}

◆ open

- (void) open

打開與 TCP 服務器的連接。

依據AComm重新實作.

◆ read

- (NSData *) 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 

使用 TSPLPGL 將打印字符串發送到指定的 IP 地址。

參數
ipAddress打印機的 IP 地址。
data要打印的數據。

◆ validateDescriptor:withPortType:

- (NSString *) validateDescriptor: (NSString *) descriptorHint
withPortType: (DescriptorPortType) portTypeHint 

使用指定的提示和端口類型驗證描述符。

參數
descriptorHint描述符的提示。
portTypeHint要驗證的端口類型。
傳回值
驗證後的描述符字符串。

◆ write:

- (void) write: (NSData *) text

將數據寫入 TCP 服務器。

參數
text要寫入服務器的數據。

依據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

將文件寫入打印機。

參數
fileName要寫入打印機的文件名。

屬性(property)說明文件

◆ connected

- (BOOL) connected
readwritenonatomicassign

指示連接是否已建立的標誌。


此類別(class) 文件是由下列檔案中產生: