Compare commits

...

1 Commits

Author SHA1 Message Date
A-O8
20f21a2624 Hussin-pr-2
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-14 03:30:58 +04:00
35 changed files with 14838 additions and 0 deletions

View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TCPIPClient", "TCPIPClient\TCPIPClient.csproj", "{0DDB2E7A-140E-4E30-80DA-3C73FE7376AD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0DDB2E7A-140E-4E30-80DA-3C73FE7376AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DDB2E7A-140E-4E30-80DA-3C73FE7376AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DDB2E7A-140E-4E30-80DA-3C73FE7376AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DDB2E7A-140E-4E30-80DA-3C73FE7376AD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View File

@ -0,0 +1,285 @@
namespace TCPIPClient
{
partial class Client
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Client));
this.tbConsole = new System.Windows.Forms.TextBox();
this.tbServerIP = new System.Windows.Forms.TextBox();
this.tbServerPort = new System.Windows.Forms.TextBox();
this.btnConnect = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.tbPayLoad = new System.Windows.Forms.TextBox();
this.btnSend = new System.Windows.Forms.Button();
this.connectionGroup = new System.Windows.Forms.GroupBox();
this.tbName = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.msgControls = new System.Windows.Forms.GroupBox();
this.btnClose = new System.Windows.Forms.Button();
this.btnlogoabt = new System.Windows.Forms.PictureBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.connectionGroup.SuspendLayout();
this.msgControls.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.btnlogoabt)).BeginInit();
this.SuspendLayout();
//
// tbConsole
//
this.tbConsole.BackColor = System.Drawing.Color.White;
this.tbConsole.Location = new System.Drawing.Point(13, 9);
this.tbConsole.Multiline = true;
this.tbConsole.Name = "tbConsole";
this.tbConsole.ReadOnly = true;
this.tbConsole.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.tbConsole.Size = new System.Drawing.Size(263, 298);
this.tbConsole.TabIndex = 0;
//
// tbServerIP
//
this.tbServerIP.Location = new System.Drawing.Point(95, 63);
this.tbServerIP.Name = "tbServerIP";
this.tbServerIP.Size = new System.Drawing.Size(181, 20);
this.tbServerIP.TabIndex = 1;
//
// tbServerPort
//
this.tbServerPort.Location = new System.Drawing.Point(94, 95);
this.tbServerPort.Name = "tbServerPort";
this.tbServerPort.Size = new System.Drawing.Size(90, 20);
this.tbServerPort.TabIndex = 2;
//
// btnConnect
//
this.btnConnect.Location = new System.Drawing.Point(190, 94);
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(86, 23);
this.btnConnect.TabIndex = 3;
this.btnConnect.Text = "Connect";
this.btnConnect.UseVisualStyleBackColor = true;
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(27, 66);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(57, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Server IP: ";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(27, 99);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(66, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Server Port: ";
//
// tbPayLoad
//
this.tbPayLoad.Location = new System.Drawing.Point(6, 19);
this.tbPayLoad.Multiline = true;
this.tbPayLoad.Name = "tbPayLoad";
this.tbPayLoad.Size = new System.Drawing.Size(294, 69);
this.tbPayLoad.TabIndex = 7;
//
// btnSend
//
this.btnSend.Location = new System.Drawing.Point(146, 94);
this.btnSend.Name = "btnSend";
this.btnSend.Size = new System.Drawing.Size(154, 23);
this.btnSend.TabIndex = 8;
this.btnSend.Text = "&Send";
this.btnSend.UseVisualStyleBackColor = true;
this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
//
// connectionGroup
//
this.connectionGroup.Controls.Add(this.tbName);
this.connectionGroup.Controls.Add(this.label3);
this.connectionGroup.Controls.Add(this.tbServerIP);
this.connectionGroup.Controls.Add(this.tbServerPort);
this.connectionGroup.Controls.Add(this.btnConnect);
this.connectionGroup.Controls.Add(this.label1);
this.connectionGroup.Controls.Add(this.label2);
this.connectionGroup.Location = new System.Drawing.Point(292, 37);
this.connectionGroup.Name = "connectionGroup";
this.connectionGroup.Size = new System.Drawing.Size(309, 135);
this.connectionGroup.TabIndex = 9;
this.connectionGroup.TabStop = false;
this.connectionGroup.Text = "Connection";
//
// tbName
//
this.tbName.Location = new System.Drawing.Point(95, 31);
this.tbName.Name = "tbName";
this.tbName.Size = new System.Drawing.Size(181, 20);
this.tbName.TabIndex = 7;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(27, 34);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(66, 13);
this.label3.TabIndex = 6;
this.label3.Text = "Your Name: ";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(407, 9);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(120, 24);
this.label4.TabIndex = 10;
this.label4.Text = "TCP/IP Client";
//
// msgControls
//
this.msgControls.Controls.Add(this.tbPayLoad);
this.msgControls.Controls.Add(this.btnSend);
this.msgControls.Enabled = false;
this.msgControls.Location = new System.Drawing.Point(292, 178);
this.msgControls.Name = "msgControls";
this.msgControls.Size = new System.Drawing.Size(309, 129);
this.msgControls.TabIndex = 11;
this.msgControls.TabStop = false;
this.msgControls.Text = "Message";
//
// btnClose
//
this.btnClose.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClose.Location = new System.Drawing.Point(563, -1);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(55, 28);
this.btnClose.TabIndex = 12;
this.btnClose.Text = "X";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnlogoabt
//
this.btnlogoabt.Image = global::TCPIPClient.Properties.Resources.icon;
this.btnlogoabt.InitialImage = global::TCPIPClient.Properties.Resources.icon;
this.btnlogoabt.Location = new System.Drawing.Point(383, 9);
this.btnlogoabt.Name = "btnlogoabt";
this.btnlogoabt.Size = new System.Drawing.Size(28, 24);
this.btnlogoabt.TabIndex = 13;
this.btnlogoabt.TabStop = false;
//this.btnlogoabt.Click += new System.EventHandler(this.btnlogoabt_Click);
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(607, 37);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(238, 251);
this.listBox1.TabIndex = 14;
//
// button2
//
this.button2.Location = new System.Drawing.Point(802, 295);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(110, 23);
this.button2.TabIndex = 15;
this.button2.Text = "Список программ";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(607, 295);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(189, 23);
this.button3.TabIndex = 16;
this.button3.Text = "Отправить программ к сервером";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Client
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(913, 320);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.btnlogoabt);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.msgControls);
this.Controls.Add(this.label4);
this.Controls.Add(this.connectionGroup);
this.Controls.Add(this.tbConsole);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximumSize = new System.Drawing.Size(913, 320);
this.MinimumSize = new System.Drawing.Size(613, 320);
this.Name = "Client";
this.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "TCPIP Client";
this.Load += new System.EventHandler(this.Client_Load_1);
this.connectionGroup.ResumeLayout(false);
this.connectionGroup.PerformLayout();
this.msgControls.ResumeLayout(false);
this.msgControls.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.btnlogoabt)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox tbConsole;
private System.Windows.Forms.TextBox tbServerIP;
private System.Windows.Forms.TextBox tbServerPort;
private System.Windows.Forms.Button btnConnect;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox tbPayLoad;
private System.Windows.Forms.Button btnSend;
private System.Windows.Forms.GroupBox connectionGroup;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.GroupBox msgControls;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.TextBox tbName;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.PictureBox btnlogoabt;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
}
}

View File

@ -0,0 +1,341 @@
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using Microsoft.Win32;
using System.Collections.Generic;
namespace TCPIPClient
{
public partial class Client : Form
{
TcpClient mTcpClient; byte[] mRx; static string strName; bool isAvailableToWrite = true;
public Client()
{
InitializeComponent();
btnClose.TabStop = false;
btnClose.FlatAppearance.BorderSize = 0;
btnClose.FlatStyle = FlatStyle.Flat;
tbConsole.TabStop = false;
tbName.TabIndex = 1;
}
void GetInstalledApps()
{
List<string> items = new List<string>();
string SoftwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
if (sk.GetValue("DisplayName") != null)
{
listBox1.Items.Add(sk.GetValue("DisplayName"));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
items.Clear();
}
}
}
private void button2_Click(object sender, EventArgs e)
{
GetInstalledApps();
}
private void Client_Load(object sender, EventArgs e){ }
IPAddress findmMyIPV4Address()
{
string strThisHostName = string.Empty;
IPHostEntry thisHostDNSEntry = null;
IPAddress[] allIPsOfThisHost = null;
IPAddress ipv4Ret = null;
try
{
strThisHostName = System.Net.Dns.GetHostName();
thisHostDNSEntry = System.Net.Dns.GetHostEntry(strThisHostName);
allIPsOfThisHost = thisHostDNSEntry.AddressList;
for (int idx = allIPsOfThisHost.Length -1; idx > 0; idx --)
{
if (allIPsOfThisHost[idx].AddressFamily == AddressFamily.InterNetwork)
{
ipv4Ret = allIPsOfThisHost[idx];
break;
}
}
} catch (Exception exc)
{
MessageBox.Show("IP Address cannot be detected. Program will still carry on running...", "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
return ipv4Ret;
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCHITTEST)
m.Result = (IntPtr)(HT_CAPTION);
}
private const int WM_NCHITTEST = 0x84;
private const int HT_CLIENT = 0x1;
private const int HT_CAPTION = 0x2;
private void btnConnect_Click(object sender, EventArgs e)
{
IPAddress ipa;
int nPort;
isAvailableToWrite = false;
try
{
if (string.IsNullOrEmpty(tbServerIP.Text) || string.IsNullOrEmpty(tbName.Text))
{
MessageBox.Show("You must enter your Name and provide an IP Address!", "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!IPAddress.TryParse(tbServerIP.Text, out ipa))
{
MessageBox.Show("Please supply an IP Address!", "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (!int.TryParse(tbServerPort.Text, out nPort))
{
nPort = 23000;
tbServerPort.Text = Convert.ToString(nPort);
}
if (!string.IsNullOrEmpty(tbName.Text))
{
strName = tbName.Text;
}
mTcpClient = new TcpClient();
mTcpClient.BeginConnect(ipa, nPort, onCompleteConnect, mTcpClient);
checkConnection();
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
void checkConnection()
{
if (isAvailableToWrite)
{
connectionGroup.Enabled = true;
msgControls.Enabled = false;
}
else if (!isAvailableToWrite)
{
connectionGroup.Enabled = false;
msgControls.Enabled = true;
tbPayLoad.Select();
}
}
void onCompleteConnect(IAsyncResult iar)
{
TcpClient tcpc;
IPAddress ipa = null;
ipa = findmMyIPV4Address();
isAvailableToWrite = false;
byte[] tx = new byte[512];
try
{
tcpc = (TcpClient)iar.AsyncState;
tcpc.EndConnect(iar);
mRx = new byte[512];
tcpc.GetStream().BeginRead(mRx, 0, mRx.Length, onCompleteReadFromServerStream, tcpc);
tx = Encoding.ASCII.GetBytes("Client has been connected. \r\nClient Name: " + strName + "\r\n"
+ "Clients IP Address: " + ipa.ToString() + "\r\n");
mTcpClient.GetStream().BeginWrite(tx, 0, tx.Length, onCompleteWriteToServer, mTcpClient);
} catch (Exception exc)
{
MessageBox.Show("The Server is offline or has actively refused your connection, please try again later!",
"TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Restart();
}
}
void onCompleteReadFromServerStream (IAsyncResult iar)
{
TcpClient tcpc;
int nCountBytesReceivedFromServer;
string strReceived;
try
{
tcpc = (TcpClient)iar.AsyncState;
nCountBytesReceivedFromServer = tcpc.GetStream().EndRead(iar);
if (nCountBytesReceivedFromServer == 0)
{
MessageBox.Show("Connection broken, retry connecting to the server!", "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
strReceived = Encoding.ASCII.GetString(mRx, 0, nCountBytesReceivedFromServer);
printLine(strReceived);
mRx = new byte[512];
tcpc.GetStream().BeginRead(mRx, 0, mRx.Length, onCompleteReadFromServerStream, tcpc);
} catch (Exception exc)
{
MessageBox.Show("Server has disconnected, please try again later!", "TCP/IP Client" , MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Application.Restart();
}
}
private void btnSend_Click(object sender, EventArgs e)
{
byte[] tx;
if (string.IsNullOrEmpty(tbPayLoad.Text))
{
MessageBox.Show("There is nothing to send as your message box is empty!", "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
try
{
if (mTcpClient != null)
{
if (mTcpClient.Client.Connected)
{
tx = Encoding.ASCII.GetBytes(strName + DateTime.Now.ToString(" [h:mm:ss] ") + ": " + tbPayLoad.Text);
mTcpClient.GetStream().BeginWrite(tx, 0, tx.Length, onCompleteWriteToServer, mTcpClient);
printLine(strName + DateTime.Now.ToString(" [h:mm:ss] ") + ": " + tbPayLoad.Text);
tbPayLoad.Clear();
} else if (!mTcpClient.Client.Connected)
{
MessageBox.Show("You are not connected to a server!", "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
msgControls.Enabled = false;
}
}
} catch (Exception exc)
{
MessageBox.Show(exc.Message, "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
void onCompleteWriteToServer (IAsyncResult iar)
{
TcpClient tcpc;
try
{
tcpc = (TcpClient)iar.AsyncState;
tcpc.GetStream().EndWrite(iar);
} catch (Exception exc)
{
MessageBox.Show(exc.Message, "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
public void printLine(string _strPrint)
{
tbConsole.Invoke(new Action<string>(doInvoke), _strPrint);
}
public void doInvoke(string _strPrint)
{
tbConsole.Text = tbConsole.Text + _strPrint + Environment.NewLine;
}
private void Client_Load_1(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
byte[] tx;
if (string.IsNullOrEmpty(listBox1.SelectedItem.ToString()))
{
MessageBox.Show("There is nothing to send as your message box is empty!", "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
try
{
if (mTcpClient != null)
{
if (mTcpClient.Client.Connected)
{
tx = Encoding.ASCII.GetBytes(strName + DateTime.Now.ToString(" [h:mm:ss] ") + ": " + listBox1.SelectedItem.ToString());
mTcpClient.GetStream().BeginWrite(tx, 0, tx.Length, onCompleteWriteToServer, mTcpClient);
printLine(strName + DateTime.Now.ToString(" [h:mm:ss] ") + ": " + listBox1.SelectedItem.ToString());
tbPayLoad.Clear();
}
else if (!mTcpClient.Client.Connected)
{
MessageBox.Show("You are not connected to a server!", "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
msgControls.Enabled = false;
}
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "TCP/IP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TCPIPClient
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Client());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TCPIPClient")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TCPIPClient")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0ddb2e7a-140e-4e30-80da-3c73fe7376ad")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TCPIPClient.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TCPIPClient.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icon {
get {
object obj = ResourceManager.GetObject("icon", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Logo {
get {
object obj = ResourceManager.GetObject("Logo", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Logo.ico;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TCPIPClient.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0DDB2E7A-140E-4E30-80DA-3C73FE7376AD}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TCPIPClient</RootNamespace>
<AssemblyName>TCPIPClient</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>C:\Users\Milan Conhye\Desktop\TCPIPClientExecutable\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>0.4.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>TCPIPClient.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>F162100917EE833F342E9B03BA052F9EB3C4C8B7</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>TCPIPClient_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Client.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Client.Designer.cs">
<DependentUpon>Client.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Client.resx">
<DependentUpon>Client.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="TCPIPClient_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
<None Include="Resources\icon.png" />
<None Include="Resources\Logo.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

View File

@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TCPIPServer", "TCPIPServer\TCPIPServer.csproj", "{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}.Debug|x86.ActiveCfg = Debug|x86
{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}.Debug|x86.Build.0 = Debug|x86
{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}.Release|Any CPU.Build.0 = Release|Any CPU
{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}.Release|x86.ActiveCfg = Release|x86
{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace TCPIPServer
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Server());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TCPIPServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TCPIPServer")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d24ee555-3ed5-4921-8324-8f14eeacf01d")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TCPIPServer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TCPIPServer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icon {
get {
object obj = ResourceManager.GetObject("icon", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TCPIPServer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,214 @@
namespace TCPIPServer
{
partial class Server
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Server));
this.tbConsoleOutput = new System.Windows.Forms.TextBox();
this.tbPort = new System.Windows.Forms.TextBox();
this.tbIPAddress = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.btnStartListening = new System.Windows.Forms.Button();
this.tbPayLoad = new System.Windows.Forms.TextBox();
this.btnSend = new System.Windows.Forms.Button();
this.msgControls = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.btnClose = new System.Windows.Forms.Button();
this.configurationGroup = new System.Windows.Forms.GroupBox();
this.btnlogoabt = new System.Windows.Forms.PictureBox();
this.msgControls.SuspendLayout();
this.configurationGroup.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.btnlogoabt)).BeginInit();
this.SuspendLayout();
//
// tbConsoleOutput
//
this.tbConsoleOutput.BackColor = System.Drawing.Color.White;
this.tbConsoleOutput.Location = new System.Drawing.Point(12, 7);
this.tbConsoleOutput.Multiline = true;
this.tbConsoleOutput.Name = "tbConsoleOutput";
this.tbConsoleOutput.ReadOnly = true;
this.tbConsoleOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.tbConsoleOutput.Size = new System.Drawing.Size(280, 213);
this.tbConsoleOutput.TabIndex = 0;
//
// tbPort
//
this.tbPort.Location = new System.Drawing.Point(214, 19);
this.tbPort.Name = "tbPort";
this.tbPort.Size = new System.Drawing.Size(76, 20);
this.tbPort.TabIndex = 1;
//
// tbIPAddress
//
this.tbIPAddress.Location = new System.Drawing.Point(53, 19);
this.tbIPAddress.Name = "tbIPAddress";
this.tbIPAddress.Size = new System.Drawing.Size(153, 20);
this.tbIPAddress.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 22);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 3;
this.label1.Text = "IP/Port: ";
//
// btnStartListening
//
this.btnStartListening.Location = new System.Drawing.Point(296, 18);
this.btnStartListening.Name = "btnStartListening";
this.btnStartListening.Size = new System.Drawing.Size(81, 23);
this.btnStartListening.TabIndex = 4;
this.btnStartListening.Text = "Listen";
this.btnStartListening.UseVisualStyleBackColor = true;
this.btnStartListening.Click += new System.EventHandler(this.btnStartListening_Click);
//
// tbPayLoad
//
this.tbPayLoad.Location = new System.Drawing.Point(6, 21);
this.tbPayLoad.Multiline = true;
this.tbPayLoad.Name = "tbPayLoad";
this.tbPayLoad.Size = new System.Drawing.Size(371, 57);
this.tbPayLoad.TabIndex = 6;
//
// btnSend
//
this.btnSend.Location = new System.Drawing.Point(248, 84);
this.btnSend.Name = "btnSend";
this.btnSend.Size = new System.Drawing.Size(129, 23);
this.btnSend.TabIndex = 7;
this.btnSend.Text = "&Send";
this.btnSend.UseVisualStyleBackColor = true;
this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
//
// msgControls
//
this.msgControls.Controls.Add(this.tbPayLoad);
this.msgControls.Controls.Add(this.btnSend);
this.msgControls.Enabled = false;
this.msgControls.Location = new System.Drawing.Point(304, 102);
this.msgControls.Name = "msgControls";
this.msgControls.Size = new System.Drawing.Size(391, 118);
this.msgControls.TabIndex = 8;
this.msgControls.TabStop = false;
this.msgControls.Text = "Message";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(452, 7);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(128, 24);
this.label2.TabIndex = 9;
this.label2.Text = "TCP/IP Server";
//
// btnClose
//
this.btnClose.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClose.Location = new System.Drawing.Point(660, -2);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(55, 28);
this.btnClose.TabIndex = 10;
this.btnClose.Text = "X";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// configurationGroup
//
this.configurationGroup.Controls.Add(this.btnStartListening);
this.configurationGroup.Controls.Add(this.tbPort);
this.configurationGroup.Controls.Add(this.tbIPAddress);
this.configurationGroup.Controls.Add(this.label1);
this.configurationGroup.Location = new System.Drawing.Point(304, 34);
this.configurationGroup.Name = "configurationGroup";
this.configurationGroup.Size = new System.Drawing.Size(391, 51);
this.configurationGroup.TabIndex = 11;
this.configurationGroup.TabStop = false;
this.configurationGroup.Text = "Configuration";
//
// btnlogoabt
//
this.btnlogoabt.Image = global::TCPIPServer.Properties.Resources.icon;
this.btnlogoabt.InitialImage = global::TCPIPServer.Properties.Resources.icon;
this.btnlogoabt.Location = new System.Drawing.Point(428, 7);
this.btnlogoabt.Name = "btnlogoabt";
this.btnlogoabt.Size = new System.Drawing.Size(28, 24);
this.btnlogoabt.TabIndex = 14;
this.btnlogoabt.TabStop = false;
//this.btnlogoabt.Click += new System.EventHandler(this.btnlogoabt_Click);
//
// Server
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(708, 231);
this.Controls.Add(this.btnlogoabt);
this.Controls.Add(this.configurationGroup);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.label2);
this.Controls.Add(this.msgControls);
this.Controls.Add(this.tbConsoleOutput);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximumSize = new System.Drawing.Size(708, 231);
this.MinimumSize = new System.Drawing.Size(708, 231);
this.Name = "Server";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "TCPIP Server";
this.Load += new System.EventHandler(this.Form1_Load);
this.msgControls.ResumeLayout(false);
this.msgControls.PerformLayout();
this.configurationGroup.ResumeLayout(false);
this.configurationGroup.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.btnlogoabt)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox tbConsoleOutput;
private System.Windows.Forms.TextBox tbPort;
private System.Windows.Forms.TextBox tbIPAddress;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnStartListening;
private System.Windows.Forms.TextBox tbPayLoad;
private System.Windows.Forms.Button btnSend;
private System.Windows.Forms.GroupBox msgControls;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.GroupBox configurationGroup;
private System.Windows.Forms.PictureBox btnlogoabt;
}
}

View File

@ -0,0 +1,222 @@
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace TCPIPServer
{
public partial class Server : Form
{
TcpListener mTCPListener; TcpClient mTCPClient; byte[] mRx;
public Server()
{
InitializeComponent();
tbConsoleOutput.TabStop = false;
}
IPAddress findMyIPV4Address()
{
string strThisHostName = string.Empty;
IPHostEntry thisHostDNSEntry = null;
IPAddress[] allIPsOfThisHost = null;
IPAddress ipv4Ret = null;
try
{strThisHostName = System.Net.Dns.GetHostName();
printLine("Host Name: " + strThisHostName);
thisHostDNSEntry = System.Net.Dns.GetHostEntry(strThisHostName);
allIPsOfThisHost = thisHostDNSEntry.AddressList;
for(int idx = allIPsOfThisHost.Length - 1; idx > 0; idx--)
{
if (allIPsOfThisHost[idx].AddressFamily == AddressFamily.InterNetwork)
{
ipv4Ret = allIPsOfThisHost[idx];
break;
}
}
} catch (Exception exc)
{
MessageBox.Show("Could not find your IPv4 Address, please manually enter and press Listen", "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
return ipv4Ret;
}
private void Form1_Load(object sender, EventArgs e)
{
IPAddress Ipa = null;
Ipa = findMyIPV4Address();
if (Ipa != null)
{
tbIPAddress.Text = Ipa.ToString();
}
btnClose.TabStop = false;
btnClose.FlatAppearance.BorderSize = 0;
btnClose.FlatStyle = FlatStyle.Flat;
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCHITTEST)
m.Result = (IntPtr)(HT_CAPTION);
}
private const int WM_NCHITTEST = 0x84;
private const int HT_CLIENT = 0x1;
private const int HT_CAPTION = 0x2;
private void btnStartListening_Click(object sender, EventArgs e)
{
IPAddress ipaddr;
int nPort;
if (!int.TryParse(tbPort.Text, out nPort))
{
nPort = 23000;
tbPort.Text = Convert.ToString(nPort);
}
if (!IPAddress.TryParse(tbIPAddress.Text, out ipaddr))
{
MessageBox.Show("Invalid IPv4 address supplied.", "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
mTCPListener = new TcpListener(ipaddr, nPort);
mTCPListener.Start();
mTCPListener.BeginAcceptTcpClient(onCompleteAcceptTcpClient, mTCPListener);
msgControls.Enabled = true;
configurationGroup.Enabled = false;
tbPayLoad.Select();
printLine("Server is listening and waiting for client to connect...");
} catch (Exception exc)
{
MessageBox.Show("Invalid IPv4 Or Local Host address supplied!", "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Restart();
}
}
void onCompleteAcceptTcpClient(IAsyncResult iar)
{
byte[] tx = new byte[512];
TcpListener tcpl = (TcpListener)iar.AsyncState;
try
{
mTCPClient = tcpl.EndAcceptTcpClient(iar);
DateTime dateTime = DateTime.Now;
tx = Encoding.ASCII.GetBytes("You are now connected to the server. You are listening to: " + tbIPAddress.Text +
":" + tbPort.Text + ". \r\n" + "Chat started on: " + dateTime.ToString() + Environment.NewLine);
printLine("\r\nChat started on: " + dateTime.ToString());
mTCPClient.GetStream().BeginWrite(tx, 0, tx.Length, onCompleteWriteToClientStream, mTCPClient);
tcpl.BeginAcceptTcpClient(onCompleteAcceptTcpClient, tcpl);
mRx = new byte[512];
mTCPClient.GetStream().BeginRead(mRx, 0, mRx.Length, onCompleteReadFromTCPClientStream, mTCPClient);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
void onCompleteReadFromTCPClientStream(IAsyncResult iar)
{
//Open a TCPClient connection
TcpClient tcpc;
//Store nothing in the Read Bytes
int nCountReadBytes = 0;
string strRecv;
try
{
tcpc = (TcpClient) iar.AsyncState;
nCountReadBytes = tcpc.GetStream().EndRead(iar);
if (nCountReadBytes <= 0)
{
printLine("Client has been disconnected. Idle for too long...");
printLine("__________________________");
return;
}
strRecv = Encoding.ASCII.GetString(mRx, 0, nCountReadBytes);
printLine(strRecv);
mRx = new byte[512];
tcpc.GetStream().BeginRead(mRx, 0, mRx.Length, onCompleteReadFromTCPClientStream, tcpc);
}
catch (Exception ex)
{
MessageBox.Show("A Client has Disconnected!", "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("Server is still listening for incoming connections...", "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
printLine("__________________________");
}
}
private void btnSend_Click(object sender, EventArgs e)
{
byte[] tx = new byte[512];
if (string.IsNullOrEmpty(tbPayLoad.Text))
{
MessageBox.Show("There is nothing to send as your message box is empty!", "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
try
{
if (mTCPClient != null)
{
if (mTCPClient.Client.Connected) {
tx = Encoding.ASCII.GetBytes("Server" + DateTime.Now.ToString(" [h:mm:ss] ") + ": " + tbPayLoad.Text);
printLine("Server" + DateTime.Now.ToString(" [h:mm:ss] ") + ": " + tbPayLoad.Text);
tbPayLoad.Clear();
mTCPClient.GetStream().BeginWrite(tx, 0, tx.Length, onCompleteWriteToClientStream, mTCPClient);
}
}
} catch (Exception exc)
{
MessageBox.Show(exc.Message, "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void onCompleteWriteToClientStream(IAsyncResult iar)
{
try
{
TcpClient tcpc = (TcpClient)iar.AsyncState;
tcpc.GetStream().EndWrite(iar);
} catch (Exception exc)
{
MessageBox.Show(exc.Message, "TCP/IP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
public void printLine(string _strPrint)
{
tbConsoleOutput.Invoke(new Action<string>(doInvoke), _strPrint);
}
public void doInvoke(string _strPrint)
{
tbConsoleOutput.Text = tbConsoleOutput.Text + _strPrint + Environment.NewLine;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,165 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B7CEDE88-5807-4960-80A7-A16EF4BEEB78}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TCPIPServer</RootNamespace>
<AssemblyName>TCPIPServer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>C:\Users\Milan Conhye\Desktop\TCPIPServerExecutable\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>0.4.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>TCPIPServer.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>5A399046DBE373F6B69804C48B85C0A705698EFB</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>TCPIPServer_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>TCPIPServer_TemporaryKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Server.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Server.Designer.cs">
<DependentUpon>Server.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Server.resx">
<DependentUpon>Server.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="TCPIPServer_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
<None Include="Resources\icon.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
<Visible>False</Visible>
<ProductName>Windows Installer 4.5</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.