Professional Documents
Culture Documents
Client 2 (C# Application)
Client 2 (C# Application)
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.Net.Sockets;
System.Net;
System.IO;
System.Security.Cryptography;
namespace ClientDiplomskiRad
{
public partial class Form1 : Form
{
TcpClient tcpclnt;
CryptographyManipulation cryptographyManipulation;
EquationFactory equationFactory;
public Form1()
{
InitializeComponent();
tcpclnt = new TcpClient();
cryptographyManipulation = new CryptographyManipulation();
equationFactory = new EquationFactory();
}
public static string GetLocalIPAddress()
{
var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
return ip.ToString();
}
}
throw new Exception("Local IP Address Not Found!");
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
try { tcpclnt.Close(); }
catch { }
}
private void button1_Click_1(object sender, EventArgs e)
{
tcpclnt = new TcpClientWithTimeout(textBoxIP.Text, Convert.ToInt32(t
extBoxPort.Text), 5000).Connect();
if (tcpclnt == null) return;
NetworkStream stream = tcpclnt.GetStream();
//tcpclnt.Connect(textBoxIP.Text, Convert.ToInt32(textBoxPort.Text))
;
//MessageBox.Show("Connected! \n Now I send request ! ");
String myIP = GetLocalIPAddress();
Stream stm = tcpclnt.GetStream();
}
}