如何发送udp到udp node.js服务器? [英] How to send udp to udp node.js server?

查看:186
本文介绍了如何发送udp到udp node.js服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新,所以我真的不知道自己在做什么,但我已经设置了一个node.js udp服务器。我想从客户端(从一个网站)发送一个数据包给它,但我不知道如何在javascript中做到这一点,或者甚至可能。我没有关注如何从node.js客户端向服务器发送数据包,而是如何编写网站以将数据包发送到node.js udp服务器。不知道这是否合理,但感谢您的帮助!

解决方案

您可能对本教程感兴趣:



http://fzysqr.com/2011/02/28/nodechat-js-using-node-js-backbone-js -socket-io-and-redis-make-a-real-time-chat-app /

它通过如何创建聊天应用程序在node.js中的细节非常详细,他甚至展示了如何使用Socket.io(一个浏览器js库)来利用web套接字实时,低延迟的响应。



正如Phihag暗示的那样,UDP不适合这种应用程序,因为UDP不能保证你的数据包能够到达目的地。在这种情况下,您肯定希望使用TCP套接字。

更多阅读: http://en.wikipedia.org/wiki/Transmission_Control_Protocol http://en.wikipedia.org/wiki/User_Datagram_Protocol

I'm very new to this so I really don't know what I'm doing, but I've setup a node.js udp server. I want to send a packet to it from the client (being from a website), but I don't know how to do that in javascript/ or if it's even possible. I'm not looking on how to send a packet from a node.js client to server, but rather how to write a website to send a packet to a node.js udp server. Not sure if that made sense, but thanks for the help!

解决方案

You may be interested in this tutorial:

http://fzysqr.com/2011/02/28/nodechat-js-using-node-js-backbone-js-socket-io-and-redis-to-make-a-real-time-chat-app/

It goes through how to create a chat application in node.js in very fine detail, he even shows how to use Socket.io (a browser js library) to utilize web sockets for realtime, low latency responses.

And as Phihag hinted at, UDP isn't good for this sort of application because UDP does not guarantee your packet will get to its destination. You definitely want to use TCP Sockets in this case.

More reading:

这篇关于如何发送udp到udp node.js服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆