简体   繁体   English

java.io套接字到node.js

[英]java.io Socket to node.js

I am trying to create a node.js command-line client for a semi-populated chat site "SpinChat". 我正在尝试为半填充的聊天网站“ SpinChat”创建一个node.js命令行客户端。 I've been doing a little research, and found that many java clients have been made using java.io. 我一直在做一些研究,发现许多Java客户端都是使用java.io制作的。 I however, wish to use node.js. 但是,我希望使用node.js。

With Java.io, i can connect to a chat server like so: 使用Java.io,我可以像这样连接到聊天服务器:

new Socket("www.spinchat.com", 3001); 

I need to be able to do with in node.js, and am not quite sure how. 我需要能够在node.js中进行操作,并且不确定如何操作。 I wish i could provide more information... but I'm hoping the answer is really simple.. perhaps a node.js edition of java.io? 我希望我能提供更多信息...但是我希望答案真的很简单。也许是java.io的node.js版本?

According to node.js docs , you can open a socket like this 根据node.js docs ,您可以像这样打开一个套接字

var socket = new net.Socket();
socket.connect(3001, "www.spinchat.com");

Here you can find additional details about the socket initialization and here you can find additional detalis about the connect() function 在这里您可以找到有关套接字初始化的其他详细信息,并且在这里可以找到有关connect()函数的其他细节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM