Clientless auto relog C#

10/05/2019 20:14 conan4#1
Hello, this is first thread to me.
i'm working on notice src and i wanna make the clientless re-log after got disconnect, i'm tried for a lot, i can make the app re-log again after the char got dc.
but i won't do it, i wanna to get disconnect from gateway and agent then try to log again.
thanks

[Only registered and activated users can see links. Click Here To Register...]
10/06/2019 23:11 JellyBitz#2
The socket still activated. The port stay as "being used" if you don't close it properly.
10/07/2019 16:45 conan4#3
Quote:
Originally Posted by JellyBitz View Post
The socket still activated. The port stay as "being used" if you don't close it properly.
thanks a lot for reply, but who i can do this? i'm tried socket.close(); but it not working.
10/08/2019 09:08 JellyBitz#4
You are not closing the connection properly by disposing only.

You have to know there exists three methods for it: Shutdown(), Disconnect() and Close().

If you plan to reuse the same socket then Disconnect will be your choice before Close it! If you don't, then try to do it properly, Shutdown (disconnect using protocols) before Close (dispose the socket).

More info can be found at this [Only registered and activated users can see links. Click Here To Register...].
10/08/2019 14:35 conan4#5
Quote:
Originally Posted by JellyBitz View Post
You are not closing the connection properly by disposing only.

You have to know there exists three methods for it: Shutdown(), Disconnect() and Close().

If you plan to reuse the same socket then Disconnect will be your choice before Close it! If you don't, then try to do it properly, Shutdown (disconnect using protocols) before Close (dispose the socket).

More info can be found at this [Only registered and activated users can see links. Click Here To Register...].
ah oky, thanks a lot for helped, i'll try <3
10/09/2019 07:50 hancook1st#6
try this
Code:
        public static void Disconnect()
        {
           try
            {
                ag_socket.Close();
                ag_socket.Dispose();
                ag_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                ag_security = new Security();
                ag_recv_buffer = new TransferBuffer(4096, 0, 0);
                ag_packets = new List<Packet>();
            }
            catch
            {
            }
        }