假设基于TCP的Web套接字已经创建了一个简单的TCP客户端,但是我无法从 echo.websocket.org 获得任何响应。我在做什么错了?
const connectionData: any = {
protocol: 'ws:',
host: 'echo.websocket.org',
port: '80'
}
var client = new net.Socket();
client.connect(connectionData, function () {
console.log('Connected');
client.write('Reply this.');
});
client.on('data', function (data) {
console.log('Received: ' + data);
});
client.on('close', function () {
console.log('Connection closed');
});