MFGS Net Socket Client
MFGSNetSocketClient Public interface
Description
Describes methods and properties of a socket client
Diagram
flowchart LR classDef interfaceStyle stroke-dasharray: 5 5; classDef abstractStyle stroke-width:4px subgraph VGWWCoreIEx VGWWCoreIEx.IExMFGSNetSocketClient[[IExMFGSNetSocketClient]] class VGWWCoreIEx.IExMFGSNetSocketClient interfaceStyle; endMembers
Properties
Public properties
| Type | Name | Methods |
|---|---|---|
object | DelimiterGetGets or sets the delimiter used to determine when a full “packet” of data has been received. | get, set |
object | DelimiterSendGets or sets the delimiter suffixed to data when sending. | get, set |
MFGSTextEncoding | EncodingThe encoding to be used when converting string or char values. | get, set |
string | HostNameGets the host name. | get |
bool | IsConnectedGets an indicator if the client is connected. | get |
int | PortGets the port number. | get |
Methods
Public methods
| Returns | Name |
|---|---|
void | Close()Close the connection. |
bool | Connect(string host, int port, int timeout)Connect to the specified host and port. |
string | Get(int timeout)Gets data from the server. |
byte``[] | GetBytes(int timeout)Get data from the server. |
void | Send(string data)Sends data to the server. |
void | SendBytes(byte``[] data)Sends data to the server. |
Details
Summary
Describes methods and properties of a socket client
Methods
Connect
public bool Connect(string host, int port, int timeout)Arguments
| Type | Name | Description |
|---|---|---|
string | host | The host to connect to. |
int | port | The port to connect to. |
int | timeout | The number of seconds to wait to make a connection. Zero or less waits indefinitely. |
Summary
Connect to the specified host and port.
Remarks
This method will block indefinitely unless a connection is made, an error occurs, or the timeout was reached.
Returns
true if the connection was successful; false if the timeout was reached.
Close
public void Close()Summary
Close the connection.
Remarks
Once the client is closed, it cannot be reused.
Get
public string Get(int timeout)Arguments
| Type | Name | Description |
|---|---|---|
int | timeout | The number of seconds to wait for data to be received. Zero or less waits indefinitely. |
Summary
Gets data from the server.
Returns
A string representing the bytes received after being converted using the specified Encoding.
GetBytes
public byte GetBytes(int timeout)Arguments
| Type | Name | Description |
|---|---|---|
int | timeout | The number of seconds to wait for data to be received. Zero or less waits indefinitely. |
Summary
Get data from the server.
Returns
A byte array of the data received
Send
public void Send(string data)Arguments
| Type | Name | Description |
|---|---|---|
string | data | The string of data to be sent. |
Summary
Sends data to the server.
Remarks
data will be converted to a byte array using the specified Encoding before being sent.
SendBytes
public void SendBytes(byte[] data)Arguments
| Type | Name | Description |
|---|---|---|
byte``[] | data | The bytes to be sent. |
Summary
Sends data to the server.
Properties
HostName
public string HostName { get; }Summary
Gets the host name.
Remarks
Is not set until Connect() is called.
Port
public int Port { get; }Summary
Gets the port number.
Remarks
Is not set until Connect() is called.
IsConnected
public bool IsConnected { get; }Summary
Gets an indicator if the client is connected.
DelimiterGet
public object DelimiterGet { get; set; }Summary
Gets or sets the delimiter used to determine when a full “packet” of data has been received.
Remarks
The delimiter will be removed from the data returned by the Get() and GetBytes() methods. If DelimiterGet is not set, or is set to null or an empty string, the Get() and GetBytes() methods will return data as it’s received. This value can be a string, char, char array, integer, or byte array. If a string, char, char array is used, the value will be converted to a byte array using the Encoding. If a integer is used, it will be directly converted to a byte value.
DelimiterSend
public object DelimiterSend { get; set; }Summary
Gets or sets the delimiter suffixed to data when sending.
Remarks
This value can be a string, char, char array, integer, or byte array. If a string, char, char array is used, the value will be converted to a byte array using the Encoding. If a integer is used, it will be directly converted to a byte value.
Encoding
public MFGSTextEncoding Encoding { get; set; }Summary
The encoding to be used when converting string or char values.
Generated with ModularDoc