Skip to content

Commit 466f866

Browse files
authored
chore: Clarify TcpSocket.createConnection() callback
1 parent 33cd0c5 commit 466f866

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff 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

123129
client.on('data', function(data) {
124130
console.log('message was received', data);
@@ -131,12 +137,6 @@ client.on('error', function(error) {
131137
client.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

0 commit comments

Comments
 (0)