genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
402 stars 157 forks source link

TcpClient Communication #48

Closed Contango1000 closed 9 years ago

Contango1000 commented 9 years ago

Looking at the code for receiving messages, i cannot see any way this will work without closing the connection. The method Socket.EndReceive(...) will only return zero (0) if the connection is closed.

There are three ways, in general, to determine when a message has completed:

  1. Close connection
  2. Prefix message with total length
  3. End the message with a marker, like or \r\n.

For binary data. option 2 is probably the best, while for string messages, marker is probably easier.

Anyway, option 1 is not a very good solution, since this will also close communication the other way.

Is there a plan for further development of this? I cannot find much information on usage of TcpClientHelper.

Regards

Paul

genemars commented 9 years ago

try to adapt this example: http://www.homegenie.it/forum/index.php?topic=495.msg2756#msg2756 how would you suggest to improve the code of TcpClientHelper class? See the code here: https://github.com/genielabs/HomeGenie/blob/master/MigFiles/SupportLibraries/TcpClientLib/TcpClient.cs Any help is highly appreciated =)