插座可靠吗? [英] Are sockets reliable?

查看:108
本文介绍了插座可靠吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用套接字在两个服务器之间发送数据是个好主意,还是我应该使用MQ之类的东西来移动数据.

Is it a good idea to use sockets to send data between two servers, or should I use something like MQ for moving data.

我的问题:如果我只需要/保证数据传输一次,套接字是否可靠?

My questions: are sockets reliable, if I need once only/assured delivery of the data?

还有其他解决方案吗?

谢谢.

推荐答案

套接字是用于执行网络通信的应用程序级API.套接字的可靠性取决于创建套接字时选择的网络协议.如果您选择TCP/IP,则将获得可靠"的传输...上限.如果选择UDP/IP,将获得不可靠"的传输.

Sockets are an application level API for performing network communication. The reliability of sockets depends on the network protocol that you select when you create the socket. If you select TCP/IP, you will get "reliable" transfer ... up to a limit. If you select UDP/IP you will get "unreliable" transfer.

如其他答案所述,TCP确保您不会丢失或破坏数据:

As stated in other answers, TCP ensures that you don't lose or corrupt data up to a point:

  1. 网络是否足够长 中断,或发送方或接收方 死于TCP/IP连接将中断 除非您不这样做,否则您将丢失数据 采取步骤重新启动 联系.
  2. 如果有网络 级别的数据损坏,有一个 不会的可能性很小 由校验和检测.
  1. if there is a long enough network outage, or the sender or receiver dies a TCP/IP connection will break and you will lose data unless you take steps to restart the connection.
  2. if there is a network level data corruption, there is a small probability that it won't be detected by the checksums.

要获得比TCP/IP提供的更高级别的可靠性保证,您需要在应用程序的基于套接字的网络层之上实施更敏感的校验和和有保证的传递机制.或使用可以为您完成工作的消息排队产品.

For higher levels of reliability guarantees than TCP/IP provides, you need to implement more sensitive checksumming and guaranteed delivery mechanisms over the top of your application's Socket-based networking layer. Or use a message queuing product that does hard the work for you.

因此,对您的问题的答案是,这取决于您使用Socket的方式以及系统所需的可靠性级别.

So the answer to your question is that it depends on how you use Sockets, and on what level of reliability your system requires.

这篇关于插座可靠吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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