C# Клиент не подключается к серверу (Socket TCP)
Написал тестовый серверсайд и клиентсайд, на локалке(localhost или же 127.0.0.1) всё работает отлично, а вот когда я или другие люди пытаются подключиться на сервер не через локалку выдаёт ошибку:
"Unhandled exception. System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (10060): Попытка установить соединение была безуспешной, т.к. от другого компьютера за требуемое время не получен нужный отклик, или было разорвано уже установленное соединение из-за неверного отклика уже подключенного компьютера"
Айпи правильный порт тоже(Открыт), брандмауэр выключил полностью.
Client:
namespace Client
{
using System.Net.Sockets;
using System.Net;
using System.Text;
class Client
{
public static void Main()
{
// Some Needed Variables
IPEndPoint address = new IPEndPoint(IPAddress.Parse("ip_here"), port_here);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// Printing Status
Console.WriteLine("Connecting..\n");
// Connecting
sock.Connect(address);
// Printing Status
Console.WriteLine("Connected!\nPlease Enter Message: ");
// Getting Answer
string answer = Console.ReadLine();
// Sending Answer
sock.Send(Encoding.ASCII.GetBytes(answer));
// Stopping
Console.ReadLine();
}
}
}
Server:
namespace Server {
using System.Net.Sockets;
using System.Net;
using System.Text;
class Server
{
public static void Main()
{
// Some Needed Variables
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint address = new IPEndPoint(IPAddress.Any, port_here);
byte[] buffer = new byte[1024];
// Printing Status
Console.WriteLine("Binding Server..");
// Binding Socket To IP
sock.Bind(address);
// Printing Status
Console.WriteLine("Listening For Connections..");
// Listening For Connections
sock.Listen(5);
do
{
// Accepting New Connection
Socket client = sock.Accept();
// Printing Connection
Console.WriteLine("{0} Is Connected!", client.RemoteEndPoint.ToString());
// Getting Bytes
int recvdata = client.Receive(buffer);
char[] chars = new char[recvdata];
int charLen = Encoding.UTF8.GetDecoder().GetChars(buffer, 0, recvdata, chars, 0);
String recv = new String(chars);
// Printing
Console.WriteLine("Recieved {0}", recv);
}
while (sock != null);
// Stopping
Console.ReadLine();
}
}
}
Где ip_here - пишу айпи, а где port_here - пишу порт