Witam mam pewien problem ponieważ chciałem zrobić proste połączenie między hostem mi klientem (zęby zrobić kiedyś możne jakiś prosty chat) i kiedy próbuje połączyć aplikacje na jednym komputerze to wszystko ładnie się łączy ale kiedy przenoszę aplikacje hosta na inny komputer to aplikacje nie chcą się połączyć
Kod Servera:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
namespace Server
{
class Program
{
static void Main(string[] args)
{
try
{
IPAddress ipAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0];
IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, 4353);
TcpListener server = new TcpListener(IPAddress.Any, 4353);
server.Start();
Console.WriteLine("Connection");
TcpClient client = server.AcceptTcpClient();
if (client.Connected != false)
{
Console.WriteLine("You Are Connected");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
Kod Klienta:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
TcpClient client = new TcpClient();
IPAddress ipAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0];
client.Connect(ipAddress, 4353);
if (client.Connected != false)
{
checkBox1.Checked = true;
}
}
}
}