ygoe / AsyncTcpClient

An asynchronous variant of TcpClient and TcpListener for .NET Standard.
153 stars 36 forks source link

Async TcpClient use within .NETStandard 2 Xamarin Forms? #5

Closed dinobu closed 5 years ago

dinobu commented 5 years ago

Hi,

I am working an a project that with following requirements

  1. Has to use TCP/IP to send and receive messages
  2. The messages are in form of byte[]
  3. I must have method like GetDataAsync() which will use your AsyncTcpClient to write asynchronously the message (send it to a server at an IP/Port) AND will then read response from that server
  4. Once entire response is received, the response will then be converted into a string
  5. The string will be parsed and used to create a List models which is then displayed in a ListView
  6. This is to be done using .NETStandard 2.0 Xamarin Forms application.

Based on above, is this library helpful in such situation? By looking at the code, I see use of Console.Read/Write which is not something you do in mobile apps.

Much appreciated,

ygoe commented 5 years ago

Not sure this is the right solution for you. You only need a client and read the full response. When do you know the response is complete? Is the connection closed by the server then? That would be easy to do with any client.

This code is meant for multiple server request/response parts and also provides a server for that. From what I've read here, you don't need the server part at all.

dinobu commented 5 years ago

That is correct, only client and only full response. The request is sent (writeAsync) and the response is awaited immediately after (readAsync). The messages are up to 1000chars long, no longer and it is not messaging going on. All initiate by user tapping on a button. Server closes connection after that. No need for server

ygoe commented 5 years ago

Then you don't need the code provided in this repository. You can use any networking methods the BCL provides you. Send the request, wait for the response, process it when the connection is closed. Simple.