Class that implements the TCP specific communication and extends the AComm class. More...
Public Types | |
enum | DescriptorPortType { DATA, MGMT, STATUS } |
Types for requesting descriptors with default port values. | |
Public Member Functions | |
TcpConnection (string descriptor) | |
Initialize new class instance based on descriptor string. More... | |
TcpConnection (string IpAddress, int port) | |
Initialize new class instance. | |
override void | Close () |
Closes a connection. | |
override void | Open () |
Opens a connection. | |
override byte[] | Read () |
Read all bytes available. | |
virtual void | Read (BinaryWriter binDataIn) |
Reads all bytes available into the stream passed in. | |
virtual void | WaitForData (int msTimeOut) |
Waits until data available BytesAvailable in current thread. Current thread sleeps until data received or timeout reached. Blocking call. More... | |
virtual void | Write (BinaryReader binReader) |
Write from input stream to output stream More... | |
override void | Write (byte[] dataOut) |
Writes all bytes from the array passed in. | |
virtual void | WriteAndWaitForResponse (BinaryWriter binDataIn, BinaryReader binDataOut, int responseStartTimeOut, int responseEndTimeOut, string completetionToken) |
Write binDataOut stream data to output stream and return data received in binDataIn stream. Data returned is any data received or up to completion token if received. Wait for response timeout before returning. More... | |
virtual byte[] | WriteAndWaitForResponse (byte[] dataOut, int responseStartTimeOut, int responseEndTimeOut, string completetionToken) |
Write byte data to output stream and return data received. Data returned is any data received or up to completion token if received. Wait for response timeout before returning. More... | |
Static Public Member Functions | |
static string | DescriptorValidate (string descriptorHint, DescriptorPortType portTypeHint) |
Validate/build descriptor string from descriptorHint that may or may not have a port. Returns valid descriptor or empty "" string. More... | |
Public Attributes | |
override string | Descriptor => $"TCP:{_ipAddress}:{_port.ToString()}" |
Returns a string description of the connection. Format: "TCP:ip:port" e.g. "TCP:127.0.0.1:9100". More... | |
Static Public Attributes | |
static readonly int | DEFAULT_DATA_PORT = 9100 |
Port for sending print data. | |
static readonly int | DEFAULT_MGMT_PORT = 3007 |
Port used to control and manage printers. | |
static readonly int | DEFAULT_STATUS_PORT = 3002 |
Port for listening to status messages from printer. More... | |
Properties | |
override int | BytesAvailable [get] |
override bool | Connected [get] |
string | IpAddress [get] |
IP address of connection. | |
int | Port [get] |
Port Number of connection. | |
Class that implements the TCP specific communication and extends the AComm class.
UniPRT.Sdk.Comm.TcpConnection.TcpConnection | ( | string | descriptor | ) |
Initialize new class instance based on descriptor string.
[in] | descriptor | Colon (:) separated string description of connection. Acceptable Formats:
|
|
static |
Validate/build descriptor string from descriptorHint that may or may not have a port. Returns valid descriptor or empty "" string.
descriptorHint accepted values:
|
virtualinherited |
Waits until data available BytesAvailable in current thread. Current thread sleeps until data received or timeout reached. Blocking call.
[in] | msTimeOut | Millisecond timeout before return if no data received. |
Implements UniPRT.Sdk.Comm.IComm.
|
virtualinherited |
Write from input stream to output stream
[in] | binReader | Source data to send |
Implements UniPRT.Sdk.Comm.IComm.
|
virtualinherited |
Write binDataOut stream data to output stream and return data received in binDataIn stream. Data returned is any data received or up to completion token if received. Wait for response timeout before returning.
[out] | binDataIn | Destination stream to store response received from connection. |
[in] | binDataOut | Source stream data to write to connection. |
[in] | responseStartTimeOut | Timeout, milliseconds, to wait for first data to be received. Time to first byte. |
[in] | responseEndTimeOut | Timeout, milliseconds, of no new data received. Time after last byte. |
[in] | completetionToken | String token denoting the end of the response expected. This can be empty string if simply want to wait for response after writing data to connection. |
Implements UniPRT.Sdk.Comm.IComm.
|
virtualinherited |
Write byte data to output stream and return data received. Data returned is any data received or up to completion token if received. Wait for response timeout before returning.
byte[] | Array of bytes received from connection. Data returned is any data received or up to completetionToken if token received |
[in] | dataOut | Source byte array to write to connection. |
[in] | responseStartTimeOut | Timeout, milliseconds, to wait for first data to be received. Time to first byte. |
[in] | responseEndTimeOut | Timeout, milliseconds, of no new data received. Time after last byte. |
[in] | completetionToken | String token denoting the end of the response expected. This can be empty string if simply want to wait for response after writing data to connection. |
Implements UniPRT.Sdk.Comm.IComm.
|
static |
Port for listening to status messages from printer.
Printer may be configured to send status messages to different ports based on the "Ret. Status Port" setting on the printer. If the "Ret. Status Port" is set to "E-NET Stat Port", the printer may send status messages to the "Status Port Number" setting which has a default of 3002.
e.g. Emulation (printer language such as PGL) diagnostic messages from printer.
e.g. Capturing ODV barcode data and grade with the following printer menu settings:
override string UniPRT.Sdk.Comm.TcpConnection.Descriptor => $"TCP:{_ipAddress}:{_port.ToString()}" |
Returns a string description of the connection. Format: "TCP:ip:port" e.g. "TCP:127.0.0.1:9100".
Format returned:
Note that "TCP" prefix on returned string to denote the type of connection.