Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about AcceptAsync in TcpAsync sample #19

Open
psantosl opened this issue Sep 26, 2017 · 2 comments
Open

Question about AcceptAsync in TcpAsync sample #19

psantosl opened this issue Sep 26, 2017 · 2 comments

Comments

@psantosl
Copy link

Hi there,
I'm trying to understand how the library works.

I wrote the following client code replacing the Client in TcpAsync:

        public static async Task Client2()
        {
            try
            {
                using (System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient())
                {
                    client.Connect(Default.IPEndPoint);

                    var st = client.GetStream();

                    using (BinaryWriter writer = new BinaryWriter(st))
                    using (BinaryReader reader = new BinaryReader(st))
                    {
                        writer.Write("Hello ");
                        writer.Flush();
                        writer.Write(true);
                        writer.Flush();
                        writer.Write(" good to go");

                        string s = reader.ReadString();

                        Console.Write(s);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Client Exception:");
                Console.WriteLine(e);
            }
        }

Well, the server never returns from AcceptAsync().

I'm familiar with socket programming, but not this.

Is this implementation somehow bound to use strings or something? I mean, shouldn't I be able to read the bytes sent by the client?

Thanks!

@txdv
Copy link
Owner

txdv commented Sep 29, 2017

https://github.com/txdv/LibuvSharp/blob/master/Examples/CrossAsync.cs is doing exactly what you want to

Please provide the entire code if you me want to debug your specific modified case

@psantosl
Copy link
Author

All I did was to modify your TcpAsync.cs example, adding my client code as above instead of the Client(). That's all. Just copy/paste this client code in your example and invoke it on Main.

I'll check CrossAsync.cs :-) Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants