client server programming using TTcpServer

I am new to C++, and I have a very basic question regarding TTcp server (C++).

I am using the following code that I copied from a website to send some numbers using TTcpServer in C++.

void __fastcall TForm2::Button1Click(TObject *Sender)
{
//Creating a stream
std::auto_ptr<TMemoryStream> myStream(new TMemoryStream);
for (byte i = 0; i < 9; i++)
{
myStream->WriteBuffer(&i,1);
}
int userValue = StrToIntDef(Edit1->Text, 0);
myStream->WriteBuffer(&userValue, 1);

//Resetting the stream position
myStream->Seek(0, 0);

//Sending the stream
TcpClient1->Active = true;
TcpClient1->SendStream(myStream.get());
TcpClient1->Active = false;
}
On the receiving end I am using the following code.

void __fastcall TForm3::TcpServer1Accept(TObject *Sender, TCustomIpClient *ClientSocket)
{
byte a[10];
ClientSocket->ReceiveBuf(a,10,0);
TDateTime now = TDateTime::CurrentDateTime();

for (int i=0; i < 9; i++)
{
Memo1->Lines->Add(IntToStr(a[i]));
}
}
I do not understand what is being sent in the byte variable, nor why a byte variable was used. I want to send some strings instead of numbers, but I don't understand what's taking place so I can't identify what to change.

Can someone explain to me why a byte variable is being used? Preferably, can you explain what's going on so I would be able to understand how to change the code and push strings instead of numbers?
closed account (S6k9GNh0)
I really don't care to interpret Delphi style classes... but I will suggest backing up a bit to BSD sockets. It might help you get a grasp of sockets although it's quite a bit more verbose.
@computerquip: Thanks a lot for your reply. Sorry I am not good at C++ and I am also not familiar with sockets. Can you explain me with some examples?
Topic archived. No new replies allowed.