File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,13 @@ import TcpSocket from 'react-native-tcp-socket';
118118### Client
119119``` javascript
120120// Create socket
121- const client = TcpSocket .createConnection (options);
121+ const client = TcpSocket .createConnection (options, () => {
122+ // Write on the socket
123+ client .write (' Hello server!' );
124+
125+ // Close socket
126+ client .destroy ();
127+ });
122128
123129client .on (' data' , function (data ) {
124130 console .log (' message was received' , data);
@@ -131,12 +137,6 @@ client.on('error', function(error) {
131137client .on (' close' , function (){
132138 console .log (' Connection closed!' );
133139});
134-
135- // Write on the socket
136- client .write (' Hello server!' );
137-
138- // Close socket
139- client .destroy ();
140140```
141141
142142### Server
You can’t perform that action at this time.
0 commit comments