tags:

views:

19

answers:

1

I have been programming with sockets for a long time and one of the things I always do is include a vli (variable length indicator) at the beginning of a message. The vli is useally 2 or 4 bytes and indicates how long the message is. The idea is that if two messages come in together you can split them apart. If a messages spans multiple packets you can buffer them together to make the message.

The question is if I am using c# TcpSocket or TcpListener to send message over TCP is it still necessary to include a vli or does the c# socket libraries take care of it and ensure that one message is send per event and a message is not broken down into multiple packets.

+1  A: 

The .NET socket classes are simply wrappers around the sockets API. You still have all the same issues you had using the API directly.

If you want complete messaging over TCP, have a look at Windows Communication Foundation (WCF) which is a .NET library. It provides the ability to transmit complete objects over a number of transports, including TCP.

Tergiver