UniPRT SDK v1.0.0.0
 
Loading...
Searching...
No Matches
TcpComm Class Reference

A class for TCP communication, inheriting from AComm and conforming to the NSStreamDelegate protocol. More...

#include <TcpComm.h>

Inheritance diagram for TcpComm:
AComm <IComm>

Instance Methods

(instancetype) - initWithIPAddress:port:
 Initializes a new instance with the given IP address and port.
 
(void) - open
 Opens the connection to the TCP server.
 
(void) - close
 Closes the connection to the TCP server.
 
(void) - write:
 Writes data to the TCP server.
 
(NSData *) - read
 Reads data from the TCP server.
 
(NSString *) - descriptorUseIp:descriptorUsePort:
 Returns a descriptor string using the specified IP and port.
 
(NSData *) - writeAndWaitForResponse:responseStartTimeOut:responseEndTimeOut:completionToken:
 Writes data to the TCP server and waits for a response.
 
(NSData *) - writeAndWaitForResponseJson:responseStartTimeOut:responseEndTimeOut:completionToken:
 Writes JSON data to the TCP server and waits for a response.
 
(typedef) - NS_ENUM
 Types of descriptor ports.
 
(NSString *) - validateDescriptor:withPortType:
 Validates the descriptor with the specified hint and port type.
 
(void) - sendPrintFile:fileName:
 Sends a print file to the specified IP address.
 
(void) - sendPrintString:data:
 Sends a print string using TSPL or PGL to the specified IP address.
 
(void) - writePrinterFile:
 Writes a file to the printer.
 
- Instance Methods inherited from AComm
(void) - readToBinaryWriter:
 Reads data into a binary writer (output stream).
 
(void) - waitForDataWithTimeout:
 Waits for data to be available within a specified timeout.
 
(void) - writeFromBinaryReader:
 Writes data from a binary reader (input stream) to the communication interface.
 
(void) - writeAndWaitForResponseToBinaryWriter:fromBinaryReader:responseStartTimeout:responseEndTimeout:completionToken:
 Writes data to the communication interface and waits for a response, using binary streams.
 

Properties

BOOL connected
 A flag indicating whether the connection is established.
 
- Properties inherited from AComm
int maxPacketSize
 The maximum packet size for communication.
 
NSString * descriptor
 The descriptor for the communication interface.
 
int bytesAvailable
 The number of bytes available to read.
 
BOOL isConnected
 A flag indicating whether the connection is established.
 
- Properties inherited from <IComm>
NSString * descriptor
 The descriptor for the communication interface.
 
int bytesAvailable
 The number of bytes available to read.
 
BOOL isConnected
 A flag indicating whether the connection is established.
 

Detailed Description

A class for TCP communication, inheriting from AComm and conforming to the NSStreamDelegate protocol.

Method Documentation

◆ close

- (void) close

Closes the connection to the TCP server.

Reimplemented from AComm.

◆ descriptorUseIp:descriptorUsePort:

- (NSString *) descriptorUseIp: (NSString *) ip
descriptorUsePort: (NSString *) port 

Returns a descriptor string using the specified IP and port.

Parameters
ipThe IP address to use in the descriptor.
portThe port to use in the descriptor.
Returns
A descriptor string.

◆ initWithIPAddress:port:

- (instancetype) initWithIPAddress: (NSString *) ipAddress
port: (NSUInteger) port 

Initializes a new instance with the given IP address and port.

Parameters
ipAddressThe IP address of the TCP server.
portThe port number of the TCP server.
Returns
An initialized instance of TcpComm, or nil if the object could not be created.

◆ NS_ENUM

- (typedef) NS_ENUM (NSInteger)
(DescriptorPortType)  

Types of descriptor ports.

This enum defines the types of descriptor ports used in the system.

Example usage:

DescriptorPortType portType = DescriptorPortTypeData;
switch (portType) {
case DescriptorPortTypeData:
// Handle data port
break;
case DescriptorPortTypeMGMT:
// Handle management port
break;
case DescriptorPortTypeStatus:
// Handle status port
break;
}

◆ open

- (void) open

Opens the connection to the TCP server.

Reimplemented from AComm.

◆ read

- (NSData *) read

Reads data from the TCP server.

Returns
The data read from the server.

Reimplemented from AComm.

◆ sendPrintFile:fileName:

- (void) sendPrintFile: (NSString *) ipAddress
fileName: (NSString *) fileName 

Sends a print file to the specified IP address.

Parameters
ipAddressThe IP address of the printer.
fileNameThe name of the file to print.

◆ sendPrintString:data:

- (void) sendPrintString: (NSString *) ipAddress
data: (NSData *) data 

Sends a print string using TSPL or PGL to the specified IP address.

Parameters
ipAddressThe IP address of the printer.
dataThe data to print.

◆ validateDescriptor:withPortType:

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

Validates the descriptor with the specified hint and port type.

Parameters
descriptorHintA hint for the descriptor.
portTypeHintThe type of port to validate.
Returns
A validated descriptor string.

◆ write:

- (void) write: (NSData *) text

Writes data to the TCP server.

Parameters
textThe data to write to the server.

Reimplemented from AComm.

◆ writeAndWaitForResponse:responseStartTimeOut:responseEndTimeOut:completionToken:

- (NSData *) writeAndWaitForResponse: (NSData *) text
responseStartTimeOut: (NSTimeInterval) responseStartTimeOut
responseEndTimeOut: (NSTimeInterval) responseEndTimeOut
completionToken: (NSString *) completionToken 

Writes data to the TCP server and waits for a response.

Parameters
textThe data to write to the server.
responseStartTimeOutThe timeout interval for the start of the response.
responseEndTimeOutThe timeout interval for the end of the response.
completionTokenA token indicating the completion of the response.
Returns
The data received in response from the server.

Reimplemented from AComm.

◆ writeAndWaitForResponseJson:responseStartTimeOut:responseEndTimeOut:completionToken:

- (NSData *) writeAndWaitForResponseJson: (NSData *) text
responseStartTimeOut: (NSTimeInterval) responseStartTimeOut
responseEndTimeOut: (NSTimeInterval) responseEndTimeOut
completionToken: (NSString *) completionToken 

Writes JSON data to the TCP server and waits for a response.

Parameters
textThe JSON data to write to the server.
responseStartTimeOutThe timeout interval for the start of the response.
responseEndTimeOutThe timeout interval for the end of the response.
completionTokenA token indicating the completion of the response.
Returns
The data received in response from the server.

◆ writePrinterFile:

- (void) writePrinterFile: (NSString *) fileName

Writes a file to the printer.

Parameters
fileNameThe name of the file to write to the printer.

Property Documentation

◆ connected

- (BOOL) connected
readwritenonatomicassign

A flag indicating whether the connection is established.


The documentation for this class was generated from the following file: