nodbus-plus 0.8.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/.readthedocs.yaml +35 -0
  2. package/LICENSE.md +21 -21
  3. package/README.md +163 -48
  4. package/docs/Makefile +20 -0
  5. package/docs/client/channel.rst +209 -0
  6. package/docs/client/nodbus_master_serial.rst +559 -0
  7. package/docs/client/nodbus_master_tcp.rst +573 -0
  8. package/docs/conf.py +41 -0
  9. package/docs/images/01-readcoils.png +0 -0
  10. package/docs/images/02-readinputs.png +0 -0
  11. package/docs/images/03-readholding.png +0 -0
  12. package/docs/images/04-readinputsreg.png +0 -0
  13. package/docs/images/05-writecoil.png +0 -0
  14. package/docs/images/06-writeregister.png +0 -0
  15. package/docs/images/15-writecoil.png +0 -0
  16. package/docs/images/16.png +0 -0
  17. package/docs/images/22-mask.png +0 -0
  18. package/docs/images/23.png +0 -0
  19. package/docs/images/7.png +0 -0
  20. package/docs/images/modbus_pdu.png +0 -0
  21. package/docs/images/serial_adu.png +0 -0
  22. package/docs/images/tcp_adu.png +0 -0
  23. package/docs/index.rst +30 -0
  24. package/docs/make.bat +35 -0
  25. package/docs/protocol/modbus_master.rst +276 -0
  26. package/docs/protocol/modbus_master_serial.rst +290 -0
  27. package/docs/protocol/modbus_master_tcp.rst +296 -0
  28. package/docs/protocol/modbus_server.rst +469 -0
  29. package/docs/protocol/modbus_server_serial.rst +543 -0
  30. package/docs/protocol/modbus_server_tcp.rst +365 -0
  31. package/docs/requirements.txt +4 -0
  32. package/docs/server/net_server.rst +242 -0
  33. package/docs/server/nodbus_serial_server.rst +652 -0
  34. package/docs/server/nodbus_tcp_server.rst +505 -0
  35. package/docs/starting.rst +192 -0
  36. package/docs/static/simple logo.jpg +0 -0
  37. package/package.json +39 -30
  38. package/samples/mb_serial_server.js +77 -0
  39. package/samples/mb_tcp_client.js +114 -0
  40. package/samples/mb_tcp_server.js +58 -0
  41. package/src/client/net/serialchannel.js +195 -0
  42. package/src/client/net/tcpchannel.js +233 -0
  43. package/src/client/net/udpchannel.js +243 -0
  44. package/src/client/nodbus_serial_client.js +577 -0
  45. package/src/client/nodbus_tcp_client.js +542 -0
  46. package/src/nodbus-plus.js +157 -110
  47. package/src/protocol/modbus_master.js +298 -961
  48. package/src/protocol/modbus_master_serial.js +247 -0
  49. package/src/protocol/modbus_master_tcp.js +219 -0
  50. package/src/protocol/modbus_server.js +936 -0
  51. package/src/protocol/modbus_server_serial.js +368 -0
  52. package/src/protocol/modbus_server_tcp.js +129 -0
  53. package/src/protocol/utils.js +296 -0
  54. package/src/server/net/serialserver.js +184 -0
  55. package/src/server/net/tcpserver.js +290 -0
  56. package/src/server/net/udpserver.js +242 -0
  57. package/src/server/nodbus_serial_server.js +238 -0
  58. package/src/server/nodbus_tcp_server.js +249 -0
  59. package/test/modbus_master.test.js +279 -0
  60. package/test/modbus_master_serial.test.js +124 -0
  61. package/test/modbus_master_tcp.test.js +178 -0
  62. package/test/modbus_server.test.js +506 -0
  63. package/test/modbus_server_serial.test.js +328 -0
  64. package/test/modbus_server_tcp.test.js +91 -0
  65. package/test/nodbus_client_serial.test.js +307 -0
  66. package/test/nodbus_client_tcp.test.js +334 -0
  67. package/test/nodbus_server_serial.test.js +255 -0
  68. package/test/nodbus_server_tcp.test.js +216 -0
  69. package/CHANGELOG.md +0 -27
  70. package/src/client/m_stcp_client.js +0 -214
  71. package/src/client/m_tcp_client.js +0 -234
  72. package/src/net/tcpclient.js +0 -173
  73. package/src/net/tcpserver.js +0 -329
  74. package/src/protocol/adu.js +0 -40
  75. package/src/protocol/ascii_adu.js +0 -139
  76. package/src/protocol/boolean_register.js +0 -78
  77. package/src/protocol/functions/Force_Multiple_Coils.js +0 -76
  78. package/src/protocol/functions/Force_Single_Coil.js +0 -54
  79. package/src/protocol/functions/Mask_Holding_Register.js +0 -47
  80. package/src/protocol/functions/Preset_Multiple_Registers.js +0 -53
  81. package/src/protocol/functions/Preset_Single_Register.js +0 -39
  82. package/src/protocol/functions/Read_Coil_Status.js +0 -59
  83. package/src/protocol/functions/Read_Holding_Registers.js +0 -52
  84. package/src/protocol/functions/Read_Input_Registers.js +0 -52
  85. package/src/protocol/functions/Read_Input_Status.js +0 -58
  86. package/src/protocol/mbap.js +0 -60
  87. package/src/protocol/modbus_device.js +0 -35
  88. package/src/protocol/modbus_slave.js +0 -522
  89. package/src/protocol/pdu.js +0 -70
  90. package/src/protocol/rtu_adu.js +0 -122
  91. package/src/protocol/serial_adu.js +0 -29
  92. package/src/protocol/tcp_adu.js +0 -84
  93. package/src/protocol/word_register.js +0 -122
  94. package/src/server/m_stcp_server.js +0 -310
  95. package/src/server/m_tcp_server.js +0 -295
  96. package/test/modbus-stcp-server-test.js +0 -72
  97. package/test/modbus-stcp-server-test1.js +0 -72
  98. package/test/modbus-tcp-client-test.js +0 -159
  99. package/test/modbus-tcp-server-test.js +0 -75
  100. package/test/modbus-tcp-server-test2.js +0 -75
  101. package/test/modbus_stcp_client.js +0 -149
@@ -0,0 +1,35 @@
1
+ # .readthedocs.yaml
2
+ # Read the Docs configuration file
3
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4
+
5
+ # Required
6
+ version: 2
7
+
8
+ # Set the OS, Python version and other tools you might need
9
+ build:
10
+ os: ubuntu-22.04
11
+ tools:
12
+ python: "3.11"
13
+ # You can also specify other tool versions:
14
+ # nodejs: "19"
15
+ # rust: "1.64"
16
+ # golang: "1.19"
17
+
18
+ # Build documentation in the "docs/" directory with Sphinx
19
+ sphinx:
20
+ configuration: docs/conf.py
21
+
22
+ # Optionally build your docs in additional formats such as PDF and ePub
23
+ # formats:
24
+ # - pdf
25
+ # - epub
26
+
27
+ # Optional but recommended, declare the Python requirements required
28
+ # to build your documentation
29
+ # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
30
+
31
+ # Optionally declare the Python requirements required to build your docs
32
+ python:
33
+ install:
34
+ - requirements: docs/requirements.txt
35
+
package/LICENSE.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 Héctor Enrique Socarrás Cabrera
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Héctor Enrique Socarrás Cabrera
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,48 +1,163 @@
1
- # Nodbus-Plus
2
-
3
- A nodejs modbus library fully writed in javascript.
4
-
5
- ## Getting Started
6
- * ### Install
7
- #### installing nodbus-plus as a node package
8
- $ npm install nodbus-plus
9
- #### installing nodbus from source
10
-
11
- * ### Basic Usage:
12
-
13
- Create a modbus tcp server.
14
-
15
- var ModbusTcpServer = require('nodbus-plus').ModbusTcpServer;
16
- var Slave = new ModbusTcpServer(502);
17
- Slave.Start();
18
- or use function CreateSlave:
19
-
20
- var nodbus = require('nodbus-plus');
21
- var ModbusTcpServer = nodbus.CreateSlave(502);
22
-
23
- Create a modbus serial slave over tcp.
24
-
25
- var ModbusSTcpServer = require('nodbus-plus').ModbusSTcpServer;
26
- var Slave = new ModbusSTcpServer(502, 1);
27
- Slave.Start();
28
-
29
- or use function CreateSlave:
30
-
31
- var nodbus = require('nodbus-plus');
32
- var ModbusSTcpServer = nodbus.CreateSlave(502, 1);
33
-
34
- Create a modbus tcp client.
35
-
36
- var ModbusTcpClient = require('nodbus-plus').ModbusTcpClient;
37
- var client = new ModbusTcpClient();
38
-
39
- ## Documentation and Tutorials
40
- See: https://github.com/hsocarras/nodbus-plus/wiki
41
- ## Contributing
42
-
43
- If you have a suggestion or found a issue, let us known and [create an issue](https://github.com/hsocarras/nodbus-plus/issues)
44
-
45
-
46
- ## License
47
-
48
- This project is licensed under the MIT License - see the LICENSE.md file for details
1
+ # Nodbus-Plus
2
+
3
+ A Modbus protocol library for Node.js, written entirely in JavaScript. It supports both Modbus Serial and Modbus TCP.
4
+
5
+ ## Introduction
6
+
7
+ Nodbus Plus has been designed as a stack for the Modbus protocol. It can be used to create both your own Modbus client and server using its API, or you can use its build in client or server and have an application with Modbus communication in just minutes.
8
+
9
+ ## Installation
10
+
11
+ ```console
12
+ $ npm install nodbus-plus
13
+ ```
14
+
15
+ ## Basic Usage:
16
+
17
+ ### Create a modbus server.
18
+
19
+ ```javascript
20
+ const nodbus = require('nodbus-plus');
21
+
22
+ //Basic config for tcp server. Default values.
23
+ const cfg = {
24
+ inputs : 2048, //total inputs
25
+ coils : 2048, //total coils
26
+ holdingRegisters : 2048, //total holding register
27
+ inputRegisters : 2048, //total input register
28
+ port : 502, //port to listen to
29
+ }
30
+
31
+ let server = nodbus.createTcpServer('tcp', cfg);
32
+ ```
33
+ The first argument for createTcpServer function is the type of transport layer used. The nodbus-plus tcp server suport 'tcp', 'udp4' and 'udp6'. To create a
34
+ serial server the procedure is the same, but calling createSerialServer function instead.
35
+
36
+ ```javascript
37
+ //Basic config for tcp server. Default values.
38
+ let cfg = {
39
+ address : 1,
40
+ transmitionMode: 0, //0-rtu, 1 - ascii
41
+ inputs : 2048,
42
+ coils : 2048,
43
+ holdingRegisters : 2048,
44
+ inputRegisters : 2048,
45
+ port : 502,
46
+ }
47
+
48
+ let server = nodbus.createSerialServer('tcp', cfg);
49
+ ```
50
+ The createSerialServer function can take the value 'serial' as fist argument as well, however the property port mus be a string
51
+ with the path to a serial port and adicional port configuration property may be needed. See nodbus-plus api for more details.
52
+
53
+ Add listeners for srever's events
54
+
55
+ ```javascript
56
+ //listenning event
57
+ server.on('listening', function(port){
58
+ console.log('Server listening on: ' + port);
59
+ });
60
+
61
+ //event emited when a request are received
62
+ server.on('request', function(sock, req){
63
+ console.log('Request received')
64
+ console.log(req)
65
+ });
66
+
67
+ //Event emited when server send a response to client
68
+ server.on('response', function(sock, res){
69
+ console.log('Responding')
70
+ console.log(res)
71
+ });
72
+
73
+ server.on('error', function(err){
74
+ console.log(err)
75
+ });
76
+ ```
77
+ Finally the server must be started.
78
+
79
+ ```javascript
80
+ server.start();
81
+ ```
82
+ ### Create a modbus client.
83
+
84
+ To create a modbus client use the functions createTcpClient or createSerialClient.
85
+
86
+ ```javascript
87
+ const nodbus = require('nodbus-plus');
88
+ let client = nodbus.createSerialClient();
89
+
90
+ //emitted when the client stablish connection with the server
91
+ client.on('connection', (id)=>{
92
+ console.log('connection stablish')
93
+ })
94
+
95
+ //emited when error occurs
96
+ client.on('error', (e)=>{
97
+ console.log(e)
98
+ })
99
+
100
+ //emitted when a request is sended to server
101
+ client.on('request', (id, req)=>{
102
+ console.log('request sended to device: ' + id);
103
+ })
104
+
105
+ //emited when no response is received
106
+ client.on('req-timeout', (id, adu)=>{
107
+ console.log('timeout')
108
+ })
109
+
110
+ //emited when a response is received
111
+ client.on('response', (id, res)=>{
112
+ console.log(res)
113
+ })
114
+ ```
115
+
116
+ Then channels must be add to the client. The client will create a connection per channel. The following example add a modbus serial over tcp server, and conect to it.
117
+
118
+ ```javascript
119
+
120
+ //channel
121
+ channelCfg = {
122
+ ip:'127.0.0.1',
123
+ port:502,
124
+ timeout:250,
125
+ }
126
+
127
+ client.addChannel('device', 'tcp1', channelCfg);
128
+ client.connect('device')
129
+
130
+ ```
131
+
132
+ Once the client is connected, and event listener configured, data can be exchange using availables modbus function.
133
+
134
+ ```javascript
135
+
136
+ //reading from cannel 'device', modbus address 1, two coils from 0 coil's address
137
+ client.readCoils('device', 1, 0, 2);
138
+
139
+ ```
140
+
141
+ ### Official Documentation
142
+
143
+ For comprehensive information on how to use NodbusPlus, refer to the [official documentation](https://nodbus-plus.readthedocs.io/en/latest/).
144
+
145
+ ### Getting Started
146
+
147
+ If you're new to NodbusPlus, the [Getting Started Guide](https://nodbus-plus.readthedocs.io/en/latest/starting.html) is a great place to begin.
148
+ It will walk you through the installation process and provide a basic usage example.
149
+
150
+
151
+ ### Examples
152
+
153
+ Inside the root folder of Nodbus plus, there is a directory './samples' that contains three example programs that make use of the library.
154
+
155
+
156
+ ## Contributing
157
+
158
+ If you have a suggestion or found a issue, let us known and [create an issue](https://github.com/hsocarras/nodbus-plus/issues)
159
+
160
+
161
+ ## License
162
+
163
+ This project is licensed under the MIT License - see the LICENSE.md file for details
package/docs/Makefile ADDED
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,209 @@
1
+ .. _nodbus_net_channel:
2
+
3
+ ===========================
4
+ API: Net Channel
5
+ ===========================
6
+
7
+ **Nodbus-Plus v1.0 Documentation**
8
+
9
+ .. contents:: Table of Contents
10
+ :depth: 3
11
+
12
+ Nodbus implementation for a modbus TCP or serial client use a netChanner object to implement the network layer. This object can be one of the following types:
13
+
14
+ * **TcpChannel**: A wrapper around node `net.Socket <https://nodejs.org/api/net.html#class-netserver>`_.
15
+
16
+ * **UdpChannel**: A wrapper around node `dgram.Socket <https://nodejs.org/api/dgram.html#class-dgramsocket>`_.
17
+
18
+ * **SerialChannel**: A wrapper around node `serialport <https://serialport.io/>`_ .
19
+
20
+
21
+ Creating a Nodbus NetChannel Instance
22
+ ====================================
23
+
24
+ new NetChannel([options])
25
+ -------------------------
26
+
27
+ * **options** <object>: Configuration object with the following properties (for tcp and udp channel) :
28
+
29
+ * port <number> : The tcp or udp port to listen. Default 502.
30
+ * ip <string>: Ip address
31
+
32
+ * **options** <object>: Configuration object with the following properties (for serial channel):
33
+
34
+ * port <string> : The path to the serial port. Example 'COM1.
35
+ * speed <number>: Enum with following baudrates in bps : 0-110, 1-300, 2-1200, 3-2400, 4-4800, 5-9600, 6-14400, 7-19200, 8-38400, 9-57600, 10-115200. Default 7.
36
+ * dataBits <number>: 7 or 8. Default 8.
37
+ * stopBits <number>: 0 or 1.
38
+ * parity <number>: Enum with following value. 0-'none', 1-'even', 2-'odd'. Default 1.
39
+ * timeBetweenFrame <number>: Number of millisends to await without receiving data to consider end of modbus frame.
40
+
41
+ Constructor for new NetChannel instance.
42
+
43
+
44
+ NetChannel Event's Hooks
45
+ ========================
46
+
47
+ The net channel object is not a event emitter, instead it uses the core channel's events to call hooks functions.
48
+
49
+ onConnectHook
50
+ -------------------------
51
+
52
+ This function is called when the core channel object emits the 'connect' event.
53
+
54
+ onDataHook
55
+ -----------
56
+
57
+
58
+ * **data** <Buffer>: Data received.
59
+
60
+ This function is called when the core channel emits the data event.
61
+
62
+ onErrorHook
63
+ -----------
64
+
65
+ * **e** <object>: error object.
66
+
67
+ This function is called when the core channel emits the 'error' event.
68
+
69
+
70
+ onMbAduHook
71
+ -------------
72
+
73
+
74
+ * **data** <Buffer>: Data received.
75
+
76
+ This hook function is similar to onDataHook, but is only called when the buffer received has been validated.
77
+
78
+
79
+ onCloseHook
80
+ ------------------
81
+
82
+ This hook function is called when core channel emits the 'close' event. It is called with no arguments.
83
+
84
+ onWriteHook
85
+ -----------
86
+
87
+ * **data** <Buffer>: Data sended.
88
+
89
+ This hook function is called when data has been sennded to a server. It is called when connection socket write some data.
90
+
91
+
92
+ NetChannel's Atributes
93
+ =======================
94
+
95
+ Atribute: netChannel.coreChannel
96
+ ---------------------------------
97
+
98
+ * <object>
99
+
100
+ * **net.Socket**: For tcp `node <https://nodejs.org/api/net.html#class-netsocket>`_.
101
+ * **dgram.Socket**: For udp `node <https://nodejs.org/api/dgram.html#class-dgramsocket>`_.
102
+ * **SerialPort**: A wrapper around node `serialport <https://serialport.io/docs/api-serialport>`_ .
103
+
104
+ This property is a node net.Socket or udp.Socket in nodbus tcpClient class or serialport from serialport library in nodbus serial client.
105
+ The netChannel class in Nodbus-Plus library is a wrapper around one of this main class.
106
+
107
+ Atribute: netChannel.ip
108
+ --------------------------------------------
109
+
110
+ * <string>: server's ip address.
111
+
112
+
113
+ Atribute: netChannel.onConnectHook
114
+ ----------------------------------------------
115
+
116
+ * <function>
117
+
118
+ This property is a reference for a hook function. See :ref:`onConnectHook`
119
+
120
+
121
+ Atribute: netChannel.onDataHook
122
+ ----------------------------------
123
+
124
+ * <function>
125
+
126
+ This property is a reference for a hook function. See :ref:`onDataHook`
127
+
128
+
129
+ Atribute: netChannel.onErrorHook
130
+ ----------------------------------
131
+
132
+ * <function>
133
+
134
+ This property is a reference for a hook function. See :ref:`onErrorHook`
135
+
136
+
137
+
138
+ Atribute: netChannel.onMbAduHook
139
+ ----------------------------------
140
+
141
+ * <function>
142
+
143
+ This property is a reference for a hook function. See :ref:`onMbAduHook`
144
+
145
+
146
+
147
+ Atribute: netChannel.onWriteHook
148
+ ----------------------------------
149
+
150
+ * <function>
151
+
152
+ This property is a reference for a hook function. See :ref:`onWriteHook`
153
+
154
+ Atribute: netChannel.port
155
+ -----------------------------
156
+
157
+ * <number>
158
+
159
+ Port where the server is listening.
160
+
161
+ Atribute: netChannel.tcpCoalescingDetection
162
+ --------------------------------------------
163
+
164
+ * <boolean>
165
+
166
+ Activate o deactivate the tcp coalscing detection function for modbus tcp protocol. Default false.
167
+
168
+
169
+ Atribute: netChannel.validateFrame
170
+ ----------------------------------
171
+
172
+ * <function>
173
+
174
+ This property is a reference to a function that performs validation.
175
+ It defines how the nodbus server executes certain protocols for validating data at the network layer level.
176
+
177
+ It is called with a Buffer as argument with the modbus frame received.
178
+
179
+
180
+ netChannel's Methods
181
+ ====================
182
+
183
+
184
+ Method: netChannel.connect()
185
+ -------------------------------
186
+
187
+ * **Return** <Promise>: Promise that will be resolve when the connection is stabished whit a socket as argument, or rejected with ip and port as parameter.
188
+
189
+ This method try to connect to channels ip and port, return a promise that resolve if the connectios is stablished successfully, otherwhise is rejected.
190
+
191
+
192
+ Method: netChannel.disconnect()
193
+ -------------------------------
194
+
195
+ * **Return** <Promise>: Promise that will be resolve when the connection is closed.
196
+
197
+ Method: netChannel.isConnected()
198
+ -------------------------------
199
+
200
+ * **Return** <bool>: Return true is the socket is connected.
201
+
202
+
203
+ Method: netChannel.write(socket, frame)
204
+ -------------------------------------------------
205
+
206
+ * **socket** <object>: buffer containig the pdu's data.
207
+ * **frame** <Buffer>: buffer with response pdu.
208
+
209
+ function to write data to a server. It takes a srteam object and a buffer to write to. When data has been send, the function calls onWriteHook funtion.