Toemsel / Network

C# Network Library

Home Page:https://push-force.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about AllowUDPConnections

SheppeR opened this issue · comments

Hi, just wondering about AllowUDPConnections set to false, why tcpconnection close and re open.
It's a bug or intended ?
If not a bug, why close and open again the tcpconnection ?

21a292ec8992a3b863bb016d1ce522cb

Because the server rejects a UDP connection and kills the related TCP connection.

Then the ClientConnectionContainer receives the info that the UDP/TCP is dead and reconnects.

Hence, if you dont allow UDP, you can't use the ClientConnectionContainer. Use the TcpConnection only instead.

Hope that helps

Thank you for your answer, I will use your suggestion.

Hum sorry but since i create a tcp connection and not a container on client, packets stopped to be send

client is connected but nothing is send from the client

        private void TestClient()
        {
            var container = ConnectionFactory.CreateTcpConnection("127.0.0.1", 8899, out _);
            container.ConnectionEstablished += Established;
        }

        private void Established(TcpConnection con, UdpConnection arg2)
        {
            Console.WriteLine($@"{con} Connection established");

            con.RegisterPacketHandler<LoginResponse>(OnResponseReceived, this);
            
            con.Send(new LoginRequest("TEST", "TEST"), this);
        }

The event subscriber seems strange with TCP and UDP as a parameter. However, please take a look at the examples:

https://www.indie-dev.at/2016/10/03/client-setup/

or on github

https://github.com/Toemsel/Network/blob/master/Examples/NetworkTestClient/SingleConnectionExample.cs

In order to help you even further, please also post the server code. Thanks

its a auto generated method with parameter from
image

The server is exactly the same code as the example from repo but AllowUDPConnections set to false

Thanks to point that out. It shouldn't be public in first place. Will change that later on.

Regarding your issue, dont use that event... It wont fire, since it will never be called (No UDP possible) and it shouldnt be visible in first place :)

Sorry for the inconvenience

no problem client send / receive packet now