Home » Community » Newbie corner » Socket Communication 101
Re: Socket Communication 101 [message #38246 is a reply to message #38236] |
Fri, 07 December 2012 20:41 |
lectus
Messages: 329 Registered: September 2006 Location: Brazil
|
Senior Member |
|
|
Since it's using TCP protocol, I believe there's a connection alive.
If you used UDP then yes, it doesn't use connections.
I think what you mean is that you can send it all in ONE chunk. Yes, it's also possible.
Maybe something like this:
String acc;
for(int i=0; i < FruitList.GetCount(); i++)
{
acc += FruitList[i];
acc += "-";
}
acc += '\n';
sock.Put(acc);
Then on the other side you can do:
String line = sock.GetLine();
String fruit;
for(int i=0;i < line.GetLength(); i++)
{
if (line[i] != '-')
fruit += line[í];
else
{
FruitList.Add(fruit);
fruit="";
}
}
Data gets sent like this:
Quote: | Apple-Banana-Orange
|
[Updated on: Fri, 07 December 2012 20:45] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue May 14 03:43:34 CEST 2024
Total time taken to generate the page: 0.02578 seconds
|