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';
118
118
### Client
119
119
``` javascript
120
120
// 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
+ });
122
128
123
129
client .on (' data' , function (data ) {
124
130
console .log (' message was received' , data);
@@ -131,12 +137,6 @@ client.on('error', function(error) {
131
137
client .on (' close' , function (){
132
138
console .log (' Connection closed!' );
133
139
});
134
-
135
- // Write on the socket
136
- client .write (' Hello server!' );
137
-
138
- // Close socket
139
- client .destroy ();
140
140
```
141
141
142
142
### Server
You can’t perform that action at this time.
0 commit comments