none
Client, Server, Testapplication RRS feed

  • Question

  • Hi,
    I read this article.

    I am looking for a client - server implementation WPF App.
    There are so many variations and it is so difficult.

    Example

    //if (!TClient.ConnectAsync(IP, Port).Wait(1000))
    //{
    //}
        
    TcpClient client = new TcpClient();
    ipAddress = IPAddress.Parse("127.0.0.1");
    await client.ConnectAsync(ipAddress, port); // connect to the server
    NetworkStream networkStream = client.GetStream();
    StreamWriter writer = new StreamWriter(networkStream);
    StreamReader reader = new StreamReader(networkStream);
    writer.AutoFlush = true;
    string requestData = "method=" + method + "&" + "data=" + data + "&eor"; // 'end-of-requet'
    await writer.WriteLineAsync(requestData);
    string response = await reader.ReadLineAsync();
    client.Close();
    // ------------------------------------------------------


    Client    Server
    I am looking for a client - server implementation
    Similar as a chat.

    Client -> Server
        Request|InfoProduct\n
    Server -> Client
        BACK|id=2844554RTZ505200100063|number=28422549|lotcode=2017122001|quantity=63|status=PASS\n

    If the server loses the connection, the client must be informed.
    --> Like some kind of full duplex.

    Problems, questions
      How I can do it?
      If no answer is given to a request, timeout after 2000ms
      The end character is not carriage return linefeed, but only \n
         In this case I can't use this ReadLineAsync
      It would be so nice if you could give me a sample
    With best regards Markus
    Saturday, December 16, 2017 1:16 PM

Answers