Hello Codeproject,
I currently have a TCP Server and Client, threaded that is.
The problem I am facing is that TCP only allows bytes to send and receive.
But it's not a problem, in fact, it's the beauty in it. But, it's impossible to
determine client and server sided how many bytes you send without having a limit,
for instance '4096'. So, what if I would want to sent a class, for instance:
public class Email
{
string Mail { get; set;}
string Recept { get; set; }
string Sent { get; set; }
public Email()
{
}
public SetEmail(string Receptant, string Sender, string Message)
{
Mail = Message;
Recept = Receptant;
Sent = Sender;
}
}
Basically, if I would use XML Serializer to serialize this class into a StringBuilder, than took the MemoryStream and made a byte[] out of it, it was possible for me to send a whole class, right? No, not at all. Since Mail, Recept, and Sent, are variabels, they can and will be changed. So assuming my message was a bit longer than 4000 characters, I would already have a problem. So my question is, if it's possible to determine how big an incoming byte array is, how would I do that? Or, does anyone have any other suggestions?