Wednesday, October 30, 2013

C# server in window and C client in linux

Hi, firstly thanks for your answer. I change my server code a little bit by using TCP Client.



namespace server_window
{
public partial class Form1 : Form
{
static TcpListener tcpListener = new TcpListener(IPAddress.Any, 1234);
TcpClient socketForClient;
public Form1()
{
InitializeComponent();
// BW_Connection.RunWorkerAsync();
}
private void BW_Connection_DoWork(object sender, DoWorkEventArgs e)
{
tcpListener.Start();
socketForClient = tcpListener.AcceptTcpClient();
this.Invoke(new MethodInvoker(delegate { TB_text.Text = "Client connected..."; }));
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
socketForClient.Close();

}

}
}

Is my code right? And my client and server are running on different PCs. I connected these 2 PCs with crossover cable.

No comments:

Post a Comment