Skip to content

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;
end

Members

Properties

Public properties

TypeNameMethods
objectDelimiterGet
Gets or sets the delimiter used to determine when a full “packet” of data has been received.
get, set
objectDelimiterSend
Gets or sets the delimiter suffixed to data when sending.
get, set
MFGSTextEncodingEncoding
The encoding to be used when converting string or char values.
get, set
stringHostName
Gets the host name.
get
boolIsConnected
Gets an indicator if the client is connected.
get
intPort
Gets the port number.
get

Methods

Public methods

ReturnsName
voidClose()
Close the connection.
boolConnect(string host, int port, int timeout)
Connect to the specified host and port.
stringGet(int timeout)
Gets data from the server.
byte``[]GetBytes(int timeout)
Get data from the server.
voidSend(string data)
Sends data to the server.
voidSendBytes(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
TypeNameDescription
stringhostThe host to connect to.
intportThe port to connect to.
inttimeoutThe 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
TypeNameDescription
inttimeoutThe 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
TypeNameDescription
inttimeoutThe 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
TypeNameDescription
stringdataThe 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
TypeNameDescription
byte``[]dataThe 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