sec.dll is a dynamic link library which allows you to control serial ports either on local or remote machine directly from your own application.


This lets you create connections and configure them without using standard configuration utility with GUI.


sec.dll should be placed in the same folder with the application which uses it. If you develop a 64-bit application, use sec64.dll instead. sec64.dll should be renamed to sec.dll


The following functions are available:


BOOL sec_ConnectService(CComVariant &host)


Connects to the Service.


host - the computer name where Serial to Ethernet Connector Service is launched.


To connect to the Service launched on the localhost, set localhost as connection parameter.


BOOL sec_DisconnectService()


Disconnects from the Service.


BOOL sec_GetConnectionsList(CComVariant *ids)


Gets the list of connections.


ids - returns the array of active connections


BOOL sec_CreateConnection(LONG ConnectionType, LONG *id);


Creates inactive connection with the default parameters.


ConnectionType - the type of created connection:


0 - TCP server

1 - TCP client

2 - UDP client


id - returns the ID of the created connection.


In case of successful creation, the function returns TRUE. Otherwise, FALSE is returned.


Use sec_GetLastError to know the error code.


To activate the connection, use sec_AddConnectionService function.


BOOL sec_DeleteAllConnections()


Deletes all active and inactive connections.


BOOL sec_DeleteConnection(LONG id)


Deletes the specified connection, regardless of whether it is active or not.


BOOL sec_AddConnectionService(LONG id)


Activates inactive connection. Sends the request on connection creation to the Service.


If the function succeeds, TRUE is returned.


BOOL sec_UpdateConnectionStatus(LONG id)


Updates connection status for the specified active connection.


id - the connection ID


Sends requests on the current connection parameters to the Service. Is recommended to be called before sec_GetParam function to activate the current connection parameters.


BOOL sec_SetParam(LONG id, CComVariant &param, CComVariant &value)


Sets connection parameter.


id - the connection ID


param - the parameter name


value - the parameter value


To apply the changes to active connection parameters, use sec_ApplyConnection function.


Parameter Name
Type
Description
type
int
Stores connection type. Read-only parameter; cannot be changed by sec_SetParam
name
string
Sets connection name.
port.name
stringCOM port name.
port.sendmode.mode
int
Packets transfer mode (numerical value).
port.sendmode.param
int
Additional required parameter, which value depends on the mode type and may contain timeout period, the number of bytes or the symbol code (numerical value).
port.type
string
COM port type: virtual or real.
port.stricted.enable
int
Indicates whether strict baud rate is enabled (0 - off, 1 - on).
port.settings
string
Includes COM port parameters in the following format: [Baudrate, Parity, Databits, Stopbits, Flowcontrol] E.g.: 9600,N,8,1
port.buffer.enable
int
Enables (1) or disables (0) buffering of data written to the COM port when no connection is established.
port.buffer.max
int
Sets the maximum size, in bytes, of the buffer enabled by port.buffer.enable (see above).
protocol.type
string
Indicates protocol type; can be either RAW or TELNET.
protocol.access.read protocol.access.write
int
Applicable only to RAW protocol.
protocol.paired.enable int
Available only for telnet protocol; indicates "Notify remote host on local port settings change" option state (0 - off; 1 - on).
protocol.telnet.dtr
protocol.telnet.rts
protocol.telnet.dcd
int
Sets response rules when control lines for telnet RFC protocol change. Parameters indicate whether control line change is allowed or not by taking 1 or 0 value correspondingly.
protocol.reconnect.enable
int
Controls "On error retry to establish connection every" option behavior.
protocol.reconnect.timeout
int
Sets reconnection interval in milliseconds.
protocol.portopencondition.enable
int
The possible values are 1 and 0. Value meaning changes depending on the connection type and port used. For details refer here.
protocol.maxconnections.value
int
The maximum number of connections to the server. Available to SERVER connection type only.
protocol.dynamic.enable
int
Manages "Allow changing local port settings" option; applicable to real ports only (1 - on; 0 - off). 
network.nagle.enable
int
Enables/disables Nagle algorithm. Applicable only to СLIENT and SERVER connection types (1 - on; 0 - off).
network.keepalive.enable
int Sending of "Keep Alive" messages is enabled when its value is 1; when its value is 0 - sending is disabled.
network.keepalive.timeout
int
Sets the interval of sending "Keep Alive" messages in milliseconds.
network.keepalive.noreply
int
The interval of sending "Keep Alive" message if the response was not received from the remote computer.
network.break.enable
int
Indicates whether "Break connection if no activity for" option is enabled (1) or not (0).
network.break.timeout
int
Indicates the interval in milliseconds after which connection should be broken.
network.incomeport.port
int
Applicable to SERVER and UDP connection types. Includes port attribute which indicates a TCP port which the server listens to incoming connections on.
network.host
array
Applicable to CLIENT and UDP connection types. Indicates remote host to be connected to. Each item in this array should include two parameters: the first one is the name of the remote host, the second one is the port to connect to.

Required parameter. If remote host is not set, localhost:5001 will be used by default.
security.auth.dll string
Name of DLL which sets the password authorization in connections; auth.dll is used by default. 
security.auth.enable
int
Enables (1)/disables (0) authorization.
security.auth.pwd
string
Sets password encryption.
security.crypt.enable
int
Enables (1)/disables (0) encryption.
security.crypt.dll
string
The name of DLL, which encrypts all the communication data; crypt.dll is used by default.
proxy.type
string
Sets proxy server's type. Available values: HTTP, SOCKS4, SOCKS5.
proxy.dns>
int
Redirects DNS requests to proxy server (1 - on, 0 - off).
proxy.host.name string
Sets proxy server name.
proxy.host.port
int
Sets TCP port of the proxy server to connect to. 
proxy.auth.user
string
Sets username. Leave this parameter empty to disable proxy authorization.
proxy.auth.pwd
string
Sets password in encrypted format.

ctrlsconn.dtr

ctrlsconn.rts

ctrlsconn.dcd

int
Manages signal lines states when connection is established.

ctrldisconn.dtr

ctrldisconn.rts

ctrldisconn.dcd

int
Manages signal lines states when connection is not established.


BOOL sec_GetParam(LONG id, CComVariant &param, CComVariant *value)


Gets the connection parameter.


id - the connection ID


param - the parameter name


value - the returned value


You can get any of the parameters listed in the description of sec_SetParam function, as well as information about the connection status.


To ensure that status parameters are actual, call sec_UpdateConnectionStatus function prior to calling sec_GetParam function.


Parameter Name
TypeDescription
status.stoppedint
1 if connection is stopped
status.port.state
int
For details refer here.
status.port.settings
string
Includes COM port parameters in the following format: [Baudrate, Parity, Databits, Stopbits, Flowcontrol] E.g.: 9600,N,8,1
status.stat.sent
int
Current statistics of sent bytes.
status.stat.recvint
Current statistics of received bytes.
status.stat.remotehost
array
Array which lists connected remote hosts. Each element describing host is presented like array and contains the following parameters in this order: [host name][port][status][sent bytes] [received bytes] [activity duration] [remote host id]
status.serverstate.state
int
For connections of SERVER type only. See table for details.
status.serverstate.activeconns
intIndicates the current number of active connections. For connections of SERVER type only.


BOOL sec_ApplyConnection(LONG id)


Saves the changes to the active connection.


Call this function to apply new connection parameters on the Service.


It is recommended to call sec_SetParam first.


BOOL sec_StopConnection(LONG id)


Stops connection. Stopped connection has the ”status.stopped” parameter set to 1.


BOOL sec_StartConnection(LONG id)


Restarts connection that has been stopped.


BOOL sec_DisconnectRemoteHostById(LONG id, LONG hostId)


Breaks network connection on given remote host


id - the connection ID


hostId - the remote host ID


sec_GetLastError()


Returns the code of the last error.