This project has moved and is read-only. For the latest updates, please go here.

Question: How would library react to multiple sockets posting/writing to a single socket

Jul 27, 2010 at 12:09 AM

hi i am writing a streaming video server and need to find out if multiple sockets can write to a single socket (video feed from multiple players going to a single player) and :


1: can we PacketProtocol.WritePacketAsync(socket, abySendData, "Video"); to each player socket that is currently connected? Would this have any side effects with this library?

2: Do we need to implement a Queue for each player or will WritePacketAsync treat each packet separately from multiple player socket in properly and transmit it in order that the packet was received to the player without corrupting the packet?


Thanks in advance for your help

Jul 28, 2010 at 2:35 PM
Edited Jul 28, 2010 at 2:35 PM

You can send the same data buffer to each connected socket without any problems.

WritePacketAsync will queue up the data correctly. The messages will arrive in order.

However, you may want to consider UDP. UDP has two advantages over TCP when it comes to media streaming:

  • Tolerates packet loss. If packets are lost when sent over the network using TCP, then it will insist that the packets be re-sent. When streaming media, it's often better to structure the data so that packet loss can be ignored (degrading quality), and this is possible using UDP. TCP will insist on perfect delivery, stopping the stream until the missed packets arrive.
  • Allows multicast. Using multicast UDP, the server only has to send out one copy of the media. Using TCP (which is always unicast), the server has to send out one copy of the media for each connected client.

UDP (and multicast UDP) has the disadvantage that it is harder to use than TCP, and Nito.Async has no support for UDP.