Witam posiadam pewien problem ponieważ chciałem zrobić proste połączenie miedzy klientem a hostem w c# i jezeli dwie aplikacje są na jednym komputerze to wszystko działa ale jak przeniosłem aplikacje hosta na inny komputer to nie mogą one się ze sobą połączyć i czy ktoś może rozwiązać mój problem
Tu jest 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
{
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());
}
}
}
}
A tu jest 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;
}
}
}
}