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?
Are there any other solutions?
Thanks.
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?
Are there any other solutions?
Thanks.
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.
As stated in other answers, TCP ensures that you don't lose or corrupt data up to a point:
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.
So the answer to your question is that it depends on how you use Sockets, and on what level of reliability your system requires.
You should probably use an MQ if you need guaranteed delivery no matter what happens (like if the other party goes offline for maintenance) and you don't want to write all the logic yourself. Sockets is what you use to connect to an other party, no matter if that party is the MQ or the final receiver of the message.