I have a server side NetworkComms Application that serves login requests from the client’s application.
In my logs, I have this output when I logged in my client application.
Console OUTPUT:
Connection Info: [TCP-E-E] xx.xxx.xx.xx:6061 -> xxx.xxx.xx.xx:8684 (e46ziHzQekaGYIb65i2-zw)
[This part immediately closes]
Connection closed with [TCP-E-S] xx.xxx.xx.xx:6061 -> xxx.xxx.xx.xx:8684 (e46ziHzQekaGYIb65i2-zw)
[Another port is assigned to my log in session]
Here is my code in C#:
private static void LoginMessage(PacketHeader header, Connection connection, string message)
{
if (connection.ConnectionAlive())
{
try
{
Console.WriteLine(“\nA message was received from ” + connection.ToString() + ” which said ‘” + message + “‘.”);
IPAddress ip = new IPAddress(connection);
string[] info = message.Split(new char[] { ‘,’ });
string user = info[0];
string pass = info[1];
Console.WriteLine(“user: ” + user);
Console.WriteLine(“pass: ” + pass);
Console.WriteLine(“ip: ” + ip.IP);
Console.WriteLine(“port: ” + ip.Port);
Console.WriteLine(“LOGIN: # of Connections: ” + NetworkComms.GetExistingConnection().Count);
string login = accounts_model.login(user, pass);
if (!login.Equals(” \”[]\””))
{
accounts_model.updateLogin(user, pass, ip.IP, int.Parse(ip.Port));
connection.SendObject(“Receiver”, login);
Console.WriteLine(“Connection based sending: “);
}
else
connection.SendObject(“Receiver”, “null”);
}
catch (Exception e)
{
Console.WriteLine(“LoginMessage: ” + e.Message);
}
}
}
Why is it so that my Connection terminates as soon as it is established?