Rapsssito / react-native-tcp-socket

React Native TCP socket API for Android, iOS & macOS with SSL/TLS support.
MIT License
315 stars 80 forks source link

EADDRINUSE (Address already in use) #70

Closed wangfpp closed 4 years ago

wangfpp commented 4 years ago

Description

EADDRINUSE (Address already in use)

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Or code:

const serverPort = 19319;
        const server = TcpSocket.createServer(function(socket) {
            socket.on('data', (data) => {
                socket.write('Echo server', data);
            });

            socket.on('error', (error) => {
                console.log('An error ocurred with client socket ', error);
            });

            socket.on('close', (error) => {
                console.log('Closed connection with ', socket.address());
            });
        }).listen({
            port: serverPort,
            host: '0.0.0.0',
            reuseAddress: true
        });

        server.on('error', (error) => {
            console.log('An error ocurred with the server', error);
        });

        server.on('close', () => {
            console.log('Server closed connection');
        });

Current behavior

socket.write('Echo server', data); cause Socket on close why?

Relevant information

OS Linux
react-native 0.63.1
react-native-tcp-socket 4.2.0
Rapsssito commented 4 years ago

@wangfpp, make sure to read the documentation for socket.write(), the method's interface is socket.write(data[, encoding][, callback]).

github-actions[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.