Network Application Programming

profilevegetass4
assignment.rar

Assignment/ACSC_424_midterm_fall_2012.pdf

1

ACSC424 – Network Application Programming – Midterm exercise

Create a chat program that will be based on client server architecture.  

The server will be responsible for connecting clients like the following diagram: 

 

 

 

 

 

 

- Each client will be connected on the server after a short authentication protocol as follows: 

o The server will be continuously listening to port 9000 for incoming connections  

o When a client is connected the server will have to accept the connection using  the following protocol: 

1. Server: OK  

2. Client: USER: <user name> 

3. Server: USER OK  or else disconnect client   

a. it depends on the user name if it is already in the users list of the server 

b. if  the  user  is  already  connected  perhaps  from  another  computer  it  should be disconnected 

4. Client: DATA 

5. Server: OK DATA 

a. When  this  procedure  is  finished  the  client  will  get  connected  to  port  9001 which is going to be used for data communications 

b. When a client is connected the server will send a message to all other  connected clients to port 9000 that e.g Client A is connected   

 

- The  server  will  reject  every  user  that  is  trying  to  register  using  an  illegal  user  name   (see step3) 

- Server must be able to connect up to five clients 

- Clients will send data (messages) to another client or to all connected clients and server will  forward it appropriately. 

 

 

 

_ _X 

Server Client A

Client C

Client B

2

 

Students will have to create two programs   a) The server, will have the following interface: 

  

 

 

 

 

 

 

 

 

 

 

b) The client, will have the following interface: 

  

 

 

 

 

 

 

 

 

 

 

Bonus part: 

Add a file exchange function between the clients.  

 

 

All the above will be returned online   

(Visual Studio C# , file and documents according to the assignment guidelines) 

IP address of server

Text to be send to remote point

Send button, when pressed data from send text box must be transmitted to the server

Data coming from other clients

Send data 

List of connected clients IP address of remote point

192.168.1.10: connected (Client 1) 192.168.1.30: connected (Client 3) 192.168.1.10: disconnected (Client 5)

Connect 

192.168.1.102: hello all (client 3: all) 192.168.1.30: this is user 5 (client 5)

User Name Client 1

Data coming from clients. Any data coming from clients will be displayed here and then will be forwarded to either another client or all of them

o Client 1 o Client 2 o Client 3 o Client 4 o Client 5  All

Select message recipient, either one of the clients or all of them

o Client 1 o Client 2 o Client 3 o Client 4 o Client 5  All

Send data 

Select a client or all of them and send a message from the server

Assignment/Help Assignment/ACSC_424_ass4_fall_2012.pdf

ACSC424 – Network Application Programming – Lab4 TCP/IP programming Efthyvoulos Kyriacou LAB EXERCISE 4 Create a chat program using TCP/IP sockets. The program will be for two nodes with the

following GUI.

Program GUI

The two users must be able to exchange messages with each other.

Create the application using your existing knowledge on TCP/IP programming. The

design thinks like number of sockets etc, will be decided by the student.

All the above will be returned within one week

(Visual Studio C# , file and documents according to the assignment guidelines)

IP address of remote point

Text to be send to remote point

Send button, when pressed data from send text box must be transmitted to the remote point

Data coming from other clients

_ _X

Send data 

Connect 

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Form1.cs

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net; using System.Net.Sockets; using System.IO; using System.Threading; namespace tcp_ip_client { public partial class tcp_client_form : Form { public tcp_client_form() { InitializeComponent(); } private void btnbrowse_Click(object sender, EventArgs e) { openFileDialog.ShowDialog(); tbFilename.Text = openFileDialog.FileName; } private void btnsend_Click(object sender, EventArgs e) { //read file using a stream Stream filestream = File.OpenRead(tbFilename.Text); // have to allocate memory for the file byte[] filebuffer = new byte[filestream.Length]; //read file into the filestream filestream.Read(filebuffer, 0, (int)filestream.Length); // have to open a TCP/IP socket in order to send the file to // the server TcpClient clientsocket = new TcpClient(tbserver.Text, 8000); //use a network stream in order to send data through TCP/IP socket NetworkStream networkstream = clientsocket.GetStream(); networkstream.Write(filebuffer, 0, filebuffer.GetLength(0)); networkstream.Close(); clientsocket.Close(); } private void tbFilename_TextChanged(object sender, EventArgs e) { } } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Form1.Designer.cs

namespace tcp_ip_client { partial class tcp_client_form { /// <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() { this.tbFilename = new System.Windows.Forms.TextBox(); this.tbserver = new System.Windows.Forms.TextBox(); this.btnbrowse = new System.Windows.Forms.Button(); this.btnsend = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); this.SuspendLayout(); // // tbFilename // this.tbFilename.Location = new System.Drawing.Point(111, 12); this.tbFilename.Name = "tbFilename"; this.tbFilename.Size = new System.Drawing.Size(230, 20); this.tbFilename.TabIndex = 0; this.tbFilename.TextChanged += new System.EventHandler(this.tbFilename_TextChanged); // // tbserver // this.tbserver.Location = new System.Drawing.Point(111, 45); this.tbserver.Name = "tbserver"; this.tbserver.Size = new System.Drawing.Size(230, 20); this.tbserver.TabIndex = 1; // // btnbrowse // this.btnbrowse.Location = new System.Drawing.Point(358, 12); this.btnbrowse.Name = "btnbrowse"; this.btnbrowse.Size = new System.Drawing.Size(77, 20); this.btnbrowse.TabIndex = 2; this.btnbrowse.Text = "Browse"; this.btnbrowse.UseVisualStyleBackColor = true; this.btnbrowse.Click += new System.EventHandler(this.btnbrowse_Click); // // btnsend // this.btnsend.Location = new System.Drawing.Point(358, 45); this.btnsend.Name = "btnsend"; this.btnsend.Size = new System.Drawing.Size(77, 20); this.btnsend.TabIndex = 3; this.btnsend.Text = "Send File"; this.btnsend.UseVisualStyleBackColor = true; this.btnsend.Click += new System.EventHandler(this.btnsend_Click); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 12); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(26, 13); this.label1.TabIndex = 4; this.label1.Text = "File:"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 49); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(94, 13); this.label2.TabIndex = 5; this.label2.Text = "Server IP address:"; // // openFileDialog // this.openFileDialog.FileName = "openFileDialog1"; // // tcp_client_form // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(451, 77); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.btnsend); this.Controls.Add(this.btnbrowse); this.Controls.Add(this.tbserver); this.Controls.Add(this.tbFilename); this.Name = "tcp_client_form"; this.Text = "\\"; this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.TextBox tbFilename; private System.Windows.Forms.TextBox tbserver; private System.Windows.Forms.Button btnbrowse; private System.Windows.Forms.Button btnsend; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.OpenFileDialog openFileDialog; } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Form1.resx

text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 17, 17

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Program.cs

using System; using System.Collections.Generic; using System.Windows.Forms; namespace tcp_ip_client { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new tcp_client_form()); } } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Properties/AssemblyInfo.cs

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("tcp_ip_client")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("tcp_ip_client")] [assembly: AssemblyCopyright("Copyright © 2008")] [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("ec2dcf14-811a-4fb7-86d6-76dbcf1f6477")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Properties/Resources.Designer.cs

//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:2.0.50727.832 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace tcp_ip_client.Properties { /// <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", "2.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 ((resourceMan == null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("tcp_ip_client.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; } } } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Properties/Resources.resx

text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Properties/Settings.Designer.cs

//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:2.0.50727.832 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace tcp_ip_client.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.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; } } } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/Properties/Settings.settings

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client/tcp_ip_client.csproj

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}</ProjectGuid> <OutputType>WinExe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>tcp_ip_client</RootNamespace> <AssemblyName>tcp_ip_client</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <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' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <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="Form1.cs"> <SubType>Form</SubType> </Compile> <Compile Include="Form1.Designer.cs"> <DependentUpon>Form1.cs</DependentUpon> </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <EmbeddedResource Include="Form1.resx"> <SubType>Designer</SubType> <DependentUpon>Form1.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> </Compile> <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> </ItemGroup> <Import Project="$(MSBuildBinPath)\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>

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client.sln

Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tcp_ip_client", "tcp_ip_client\tcp_ip_client.csproj", "{8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}.Release|Any CPU.ActiveCfg = Release|Any CPU {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/Backup/tcp_ip_client.suo

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/bin/Debug/tcp_ip_client.exe

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/bin/Debug/tcp_ip_client.pdb

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/bin/Debug/tcp_ip_client.vshost.exe

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/bin/Debug/tcp_ip_client.vshost.exe.manifest

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Form1.cs

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net; using System.Net.Sockets; using System.IO; using System.Threading; namespace tcp_ip_client { public partial class tcp_client_form : Form { TcpClient clientsocket; NetworkStream networkstream; Socket handlerSocket; delegate void SetTextCallback(string text); delegate void SetText2Callback(string text); public tcp_client_form() { InitializeComponent(); Thread thdListener = new Thread(new ThreadStart(listenerThread)); thdListener.Start(); } private void btnbrowse_Click(object sender, EventArgs e) { clientsocket = new TcpClient(tbserver.Text, 8000); //use a network stream in order to send data through TCP/IP socket networkstream = clientsocket.GetStream(); } private void btnsend_Click(object sender, EventArgs e) { Byte[] sendBytes=Encoding.ASCII.GetBytes(tbsndtxt.Text); networkstream.Write(sendBytes, 0, sendBytes.GetLength(0)); tbsndtxt.Clear(); } private void tbFilename_TextChanged(object sender, EventArgs e) { } private void label1_Click(object sender, EventArgs e) { } public void listenerThread() { TcpListener tcplisten = new TcpListener(8000); tcplisten.Start(1); this.SetText("Listening mode"); while (true) { handlerSocket = tcplisten.AcceptSocket(); if (handlerSocket.Connected) { this.SetText("Connected"); ThreadStart thdstHandler=new ThreadStart(handlerThread); Thread thdHandler=new Thread(thdstHandler); thdHandler.Start(); } } } public void handlerThread() { NetworkStream networkstream1=new NetworkStream(handlerSocket); int thisRead=0; int blocksize=1024; Byte[] databyte=new Byte[blocksize]; while(true) { thisRead=networkstream1.Read(databyte,0,blocksize); string returnData = Encoding.ASCII.GetString(databyte); this.SetText2(returnData); //tbrcvtxt.Text = returnData; } } private void SetText(string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.tbconnect.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetText); this.Invoke(d, new object[] { text }); } else { this.tbconnect.Text = text; } } private void SetText2(string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.tbrcvtxt.InvokeRequired) { SetText2Callback d = new SetText2Callback(SetText2); this.Invoke(d, new object[] { text }); } else { this.tbrcvtxt.Text = text; } } private void tbrcvtxt_TextChanged(object sender, EventArgs e) { } } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Form1.Designer.cs

namespace tcp_ip_client { partial class tcp_client_form { /// <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() { this.tbsndtxt = new System.Windows.Forms.TextBox(); this.tbserver = new System.Windows.Forms.TextBox(); this.btnconnect = new System.Windows.Forms.Button(); this.btnsend = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.tbrcvtxt = new System.Windows.Forms.TextBox(); this.tbconnect = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // tbsndtxt // this.tbsndtxt.Location = new System.Drawing.Point(111, 38); this.tbsndtxt.Multiline = true; this.tbsndtxt.Name = "tbsndtxt"; this.tbsndtxt.Size = new System.Drawing.Size(230, 134); this.tbsndtxt.TabIndex = 0; this.tbsndtxt.TextChanged += new System.EventHandler(this.tbFilename_TextChanged); // // tbserver // this.tbserver.Location = new System.Drawing.Point(111, 12); this.tbserver.Name = "tbserver"; this.tbserver.Size = new System.Drawing.Size(230, 20); this.tbserver.TabIndex = 1; // // btnconnect // this.btnconnect.Location = new System.Drawing.Point(358, 12); this.btnconnect.Name = "btnconnect"; this.btnconnect.Size = new System.Drawing.Size(77, 20); this.btnconnect.TabIndex = 2; this.btnconnect.Text = "Connect"; this.btnconnect.UseVisualStyleBackColor = true; this.btnconnect.Click += new System.EventHandler(this.btnbrowse_Click); // // btnsend // this.btnsend.Location = new System.Drawing.Point(264, 178); this.btnsend.Name = "btnsend"; this.btnsend.Size = new System.Drawing.Size(77, 20); this.btnsend.TabIndex = 3; this.btnsend.Text = "Send text"; this.btnsend.UseVisualStyleBackColor = true; this.btnsend.Click += new System.EventHandler(this.btnsend_Click); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 38); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(46, 13); this.label1.TabIndex = 4; this.label1.Text = "Send txt"; this.label1.Click += new System.EventHandler(this.label1_Click); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 16); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(94, 13); this.label2.TabIndex = 5; this.label2.Text = "Server IP address:"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 228); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(70, 13); this.label3.TabIndex = 7; this.label3.Text = "Received txt"; // // tbrcvtxt // this.tbrcvtxt.ForeColor = System.Drawing.SystemColors.ActiveCaption; this.tbrcvtxt.Location = new System.Drawing.Point(111, 204); this.tbrcvtxt.Multiline = true; this.tbrcvtxt.Name = "tbrcvtxt"; this.tbrcvtxt.Size = new System.Drawing.Size(230, 158); this.tbrcvtxt.TabIndex = 6; this.tbrcvtxt.TextChanged += new System.EventHandler(this.tbrcvtxt_TextChanged); // // tbconnect // this.tbconnect.Location = new System.Drawing.Point(29, 371); this.tbconnect.Name = "tbconnect"; this.tbconnect.ReadOnly = true; this.tbconnect.Size = new System.Drawing.Size(410, 20); this.tbconnect.TabIndex = 8; // // tcp_client_form // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(451, 403); this.Controls.Add(this.tbconnect); this.Controls.Add(this.label3); this.Controls.Add(this.tbrcvtxt); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.btnsend); this.Controls.Add(this.btnconnect); this.Controls.Add(this.tbserver); this.Controls.Add(this.tbsndtxt); this.Name = "tcp_client_form"; this.Text = "\\"; this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.TextBox tbsndtxt; private System.Windows.Forms.TextBox tbserver; private System.Windows.Forms.Button btnconnect; private System.Windows.Forms.Button btnsend; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox tbrcvtxt; private System.Windows.Forms.TextBox tbconnect; } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Form1.resx

text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/GenerateResource-ResGen.read.1.tlog

^G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\LAB_4_TCP_IP_CLIENT_SERVER\TCP_IP_CLIENT\TCP_IP_CLIENT\FORM1.RESX ^G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\LAB_4_TCP_IP_CLIENT_SERVER\TCP_IP_CLIENT\TCP_IP_CLIENT\PROPERTIES\RESOURCES.RESX ^G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\ASSIGNMENT_4_SOLUTION\TCP_IP_CLIENT\TCP_IP_CLIENT\PROPERTIES\RESOURCES.RESX C:\WINDOWS\MICROSOFT.NET\FRAMEWORK\V2.0.50727\CONFIG\SECURITY.CONFIG C:\WINDOWS\MICROSOFT.NET\FRAMEWORK\V2.0.50727\CONFIG\ENTERPRISESEC.CONFIG ^G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\ASSIGNMENT_4_SOLUTION\TCP_IP_CLIENT\TCP_IP_CLIENT\FORM1.RESX C:\WINDOWS\MICROSOFT.NET\FRAMEWORK\V2.0.50727\CONFIG\SECURITY.CONFIG C:\WINDOWS\MICROSOFT.NET\FRAMEWORK\V2.0.50727\CONFIG\ENTERPRISESEC.CONFIG

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/GenerateResource-ResGen.write.1.tlog

^G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\LAB_4_TCP_IP_CLIENT_SERVER\TCP_IP_CLIENT\TCP_IP_CLIENT\FORM1.RESX|G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\LAB_4_TCP_IP_CLIENT_SERVER\TCP_IP_CLIENT\TCP_IP_CLIENT\PROPERTIES\RESOURCES.RESX G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\LAB_4_TCP_IP_CLIENT_SERVER\TCP_IP_CLIENT\TCP_IP_CLIENT\OBJ\DEBUG\TCP_IP_CLIENT.TCP_CLIENT_FORM.RESOURCES G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\LAB_4_TCP_IP_CLIENT_SERVER\TCP_IP_CLIENT\TCP_IP_CLIENT\OBJ\DEBUG\TCP_IP_CLIENT.PROPERTIES.RESOURCES.RESOURCES ^G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\ASSIGNMENT_4_SOLUTION\TCP_IP_CLIENT\TCP_IP_CLIENT\FORM1.RESX|G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\ASSIGNMENT_4_SOLUTION\TCP_IP_CLIENT\TCP_IP_CLIENT\PROPERTIES\RESOURCES.RESX G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\ASSIGNMENT_4_SOLUTION\TCP_IP_CLIENT\TCP_IP_CLIENT\OBJ\DEBUG\TCP_IP_CLIENT.TCP_CLIENT_FORM.RESOURCES G:\EFTHYVOULOS\FREDERICK\LESSONS\ACSC_424_NETWORK_APPLICATION_PROGRAMMING\LABS\ASSIGNMENT_4_SOLUTION\TCP_IP_CLIENT\TCP_IP_CLIENT\OBJ\DEBUG\TCP_IP_CLIENT.PROPERTIES.RESOURCES.RESOURCES

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/tcp_ip_client.csproj.FileListAbsolute.txt

G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.exe G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.pdb G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\bin\Debug\tcp_ip_client.exe G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\bin\Debug\tcp_ip_client.pdb G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\ResolveAssemblyReference.cache G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.tcp_client_form.resources G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.Properties.Resources.resources G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\GenerateResource-ResGen.read.1.tlog G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\GenerateResource-ResGen.write.1.tlog G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.exe G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.pdb G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\obj\Debug\ResolveAssemblyReference.cache G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.tcp_client_form.resources G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.Properties.Resources.resources G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\obj\Debug\GenerateResource-ResGen.read.1.tlog G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\obj\Debug\GenerateResource-ResGen.write.1.tlog G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\bin\Debug\tcp_ip_client.exe G:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\assignment_4_solution\tcp_ip_client\tcp_ip_client\bin\Debug\tcp_ip_client.pdb

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/tcp_ip_client.csproj.GenerateResource.Cache

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/tcp_ip_client.exe

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/tcp_ip_client.pdb

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/tcp_ip_client.Properties.Resources.resources

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/tcp_ip_client.tcp_client_form.resources

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/tcp_ip_client.csproj.FileList.txt

bin\Debug\tcp_ip_client.exe bin\Debug\tcp_ip_client.pdb obj\Debug\ResolveAssemblyReference.cache obj\Debug\tcp_ip_client.tcp_client_form.resources obj\Debug\tcp_ip_client.Properties.Resources.resources obj\Debug\tcp_ip_client.csproj.GenerateResource.Cache obj\Debug\tcp_ip_client.exe obj\Debug\tcp_ip_client.pdb

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/obj/tcp_ip_client.csproj.FileListAbsolute.txt

C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\spring_2008\labs\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.exe C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\spring_2008\labs\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.pdb C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.exe C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.pdb C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\bin\Debug\tcp_ip_client.exe C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\bin\Debug\tcp_ip_client.pdb C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\ResolveAssemblyReference.cache C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.tcp_client_form.resources C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.Properties.Resources.resources C:\efthyvoulos\frederick\lessons\ACSC_424_Net_app_progr\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.csproj.GenerateResource.Cache C:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.exe C:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.pdb C:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\bin\Debug\tcp_ip_client.exe C:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\bin\Debug\tcp_ip_client.pdb C:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\ResolveAssemblyReference.cache C:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.tcp_client_form.resources C:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.Properties.Resources.resources C:\efthyvoulos\frederick\lessons\ACSC_424_Network_application_programming\labs\lab_4_tcp_ip_client_server\tcp_ip_client\tcp_ip_client\obj\Debug\tcp_ip_client.csproj.GenerateResource.Cache

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Program.cs

using System; using System.Collections.Generic; using System.Windows.Forms; namespace tcp_ip_client { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new tcp_client_form()); } } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Properties/AssemblyInfo.cs

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("tcp_ip_client")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("tcp_ip_client")] [assembly: AssemblyCopyright("Copyright © 2008")] [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("ec2dcf14-811a-4fb7-86d6-76dbcf1f6477")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Properties/Resources.Designer.cs

//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.488 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace tcp_ip_client.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("tcp_ip_client.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; } } } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Properties/Resources.resx

text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Properties/Settings.Designer.cs

//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.488 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace tcp_ip_client.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.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; } } } }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/Properties/Settings.settings

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client/tcp_ip_client.csproj

Debug AnyCPU 8.0.50727 2.0 {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD} WinExe Properties tcp_ip_client tcp_ip_client v2.0 2.0 true full false bin\Debug\ DEBUG;TRACE prompt 4 AllRules.ruleset pdbonly true bin\Release\ TRACE prompt 4 AllRules.ruleset Form Form1.cs Designer Form1.cs ResXFileCodeGenerator Resources.Designer.cs Designer True Resources.resx True SettingsSingleFileGenerator Settings.Designer.cs True Settings.settings True

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client.sln

Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tcp_ip_client", "tcp_ip_client\tcp_ip_client.csproj", "{8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}.Release|Any CPU.ActiveCfg = Release|Any CPU {8C1EE43D-8DFF-4897-B39E-F8E9E12B2AFD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/tcp_ip_client.suo

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/UpgradeLog.XML

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/_UpgradeReport_Files/UpgradeReport.css

BODY { BACKGROUND-COLOR: white; FONT-FAMILY: "Verdana", sans-serif; FONT-SIZE: 100%; MARGIN-LEFT: 0px; MARGIN-TOP: 0px } P { FONT-FAMILY: "Verdana", sans-serif; FONT-SIZE: 70%; LINE-HEIGHT: 12pt; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 10px; MARGIN-TOP: 10px } .note { BACKGROUND-COLOR: #ffffff; COLOR: #336699; FONT-FAMILY: "Verdana", sans-serif; FONT-SIZE: 100%; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-TOP: 0px; PADDING-RIGHT: 10px } .infotable { BACKGROUND-COLOR: #f0f0e0; BORDER-BOTTOM: #ffffff 0px solid; BORDER-COLLAPSE: collapse; BORDER-LEFT: #ffffff 0px solid; BORDER-RIGHT: #ffffff 0px solid; BORDER-TOP: #ffffff 0px solid; FONT-SIZE: 70%; MARGIN-LEFT: 10px } .issuetable { BACKGROUND-COLOR: #ffffe8; BORDER-COLLAPSE: collapse; COLOR: #000000; FONT-SIZE: 100%; MARGIN-BOTTOM: 10px; MARGIN-LEFT: 13px; MARGIN-TOP: 0px } .issuetitle { BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #dcdcdc 1px solid; BORDER-TOP: #dcdcdc 1px; COLOR: #003366; FONT-WEIGHT: normal } .header { BACKGROUND-COLOR: #cecf9c; BORDER-BOTTOM: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; COLOR: #000000; FONT-WEIGHT: bold } .issuehdr { BACKGROUND-COLOR: #E0EBF5; BORDER-BOTTOM: #dcdcdc 1px solid; BORDER-TOP: #dcdcdc 1px solid; COLOR: #000000; FONT-WEIGHT: normal } .issuenone { BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; BORDER-RIGHT: 0px; BORDER-TOP: 0px; COLOR: #000000; FONT-WEIGHT: normal } .content { BACKGROUND-COLOR: #e7e7ce; BORDER-BOTTOM: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; PADDING-LEFT: 3px } .issuecontent { BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #dcdcdc 1px solid; BORDER-TOP: #dcdcdc 1px solid; PADDING-LEFT: 3px } A:link { COLOR: #cc6633; TEXT-DECORATION: underline } A:visited { COLOR: #cc6633; } A:active { COLOR: #cc6633; } A:hover { COLOR: #cc3300; TEXT-DECORATION: underline } H1 { BACKGROUND-COLOR: #003366; BORDER-BOTTOM: #336699 6px solid; COLOR: #ffffff; FONT-SIZE: 130%; FONT-WEIGHT: normal; MARGIN: 0em 0em 0em -20px; PADDING-BOTTOM: 8px; PADDING-LEFT: 30px; PADDING-TOP: 16px } H2 { COLOR: #000000; FONT-SIZE: 80%; FONT-WEIGHT: bold; MARGIN-BOTTOM: 3px; MARGIN-LEFT: 10px; MARGIN-TOP: 20px; PADDING-LEFT: 0px } H3 { COLOR: #000000; FONT-SIZE: 80%; FONT-WEIGHT: bold; MARGIN-BOTTOM: -5px; MARGIN-LEFT: 10px; MARGIN-TOP: 20px } H4 { COLOR: #000000; FONT-SIZE: 70%; FONT-WEIGHT: bold; MARGIN-BOTTOM: 0px; MARGIN-TOP: 15px; PADDING-BOTTOM: 0px } UL { COLOR: #000000; FONT-SIZE: 70%; LIST-STYLE: square; MARGIN-BOTTOM: 0pt; MARGIN-TOP: 0pt } OL { COLOR: #000000; FONT-SIZE: 70%; LIST-STYLE: square; MARGIN-BOTTOM: 0pt; MARGIN-TOP: 0pt } LI { LIST-STYLE: square; MARGIN-LEFT: 0px } .expandable { CURSOR: hand } .expanded { color: black } .collapsed { DISPLAY: none } .foot { BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #cecf9c 1px solid; BORDER-TOP: #cecf9c 2px solid } .settings { MARGIN-LEFT: 25PX; } .help { TEXT-ALIGN: right; margin-right: 10px; }

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/_UpgradeReport_Files/UpgradeReport.xslt

Solution: Project: Filename Status Errors Warnings javascript:document.images[' '].click() src Converted Converted src Conversion Report - : files 1 file Converted: Not converted: : Conversion Report function outliner () { oMe = window.event.srcElement //get child element var child = document.all[event.srcElement.getAttribute("child",false)]; //if child element exists, expand or collapse it. if (null != child) child.className = child.className == "collapsed" ? "expanded" : "collapsed"; } function changepic() { uMe = window.event.srcElement; var check = uMe.src.toLowerCase(); if (check.lastIndexOf("upgradereport_plus.gif") != -1) { uMe.src = "_UpgradeReport_Files/UpgradeReport_Minus.gif" } else { uMe.src = "_UpgradeReport_Files/UpgradeReport_Plus.gif" } } Conversion Report - Time of Conversion: Conversion Settings

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/_UpgradeReport_Files/UpgradeReport_Minus.gif

Assignment/Help Assignment/assignment_4_solution_tcp_ip_communication_program/tcp_ip_client/_UpgradeReport_Files/UpgradeReport_Plus.gif

Assignment/Report example.doc

image4.png

UDP programming

Computer Science

Course Code: ACSC424

Academic Year: 2012-2013

Semester: Fall

By

Marios Andreou

Date Submitted: 23-01-2012

Lecturer: Dr. Kyriacou Efthyvoulos

Table of contents

Application’s details 2

Explanation of Main Coding 3

Testing 5

Bibliography-References 5

Application’s details

The application should be able to be used by different clients that want to send text messages to each other in a network environment using the UDP protocol. Such an application is a P2P model and in such a model each application should be able to act both as a server and a client, server when is listening for incoming messages and client when wants to send a message.

The layout of the application should have 2 textbox, 1 list box and a button. In the first textbox the user can put the hostname or the IP address of the host that wants to send message to, and in the second textbox the user can put the data that the message should consist of. The list box items are the incoming messages from other applications.

As it was said above the application to achieve communication is using UDP protocol and that protocol’s class we are using in the code. The name of that class that can be found in System.Net namespace is UdpClient.

The application is looking like the following picture.

image2.png

Explanation of Main Coding

As I was said before the application can act and as a server and a client, in this segment I would explain the two phases from the coding perspective.

Server

When the application form is loaded a new thread (other that the main thread that the form is running on.) is start and that thread points to a method that handles incoming requests from other applications by using the UdpClient class and the IPEndPoint to read the incoming data from the other application.

Crucial Points:

· In order for the application to continuously listen the code segment of listening is placed in an infinite loop.

· In order for the thread that we custom built to be able to access the main thread and add data to the list box a delegate is used.

The code is explained in detail with comments in the Appendix segment.

private void frmMain_Load(object sender, EventArgs e)

{

updServer = new Thread(new ThreadStart(serverThread));

updServer.Start();

}

private void serverThread()

{

try

{

using (UdpClient client = new UdpClient(11984))

{

while (true)

{

Byte[] receiveData = client.Receive

(ref remoteIp);

string data = Encoding.ASCII.GetString(receiveData);

if (IncomingMsgList.InvokeRequired)

{

setTextCall d = new setTextCall(setText);

this.Invoke(d, data);

}

}

}

}catch (Exception ex) {

MessageBox.Show(ex.Message);

}

}

Client

Client phase is more programmatically easy to achieve and again we are using the UdpClient class to send the data that we wrote in the text box of data to the IP address or host name we wrote in the address textbox.

Again detail explanation with comments is shown in the Appendix segment.

private void btnSend_Click(object sender, EventArgs e)

{

try

{

using (UdpClient client = new UdpClient())

{

client.Connect(Dns.GetHostEntry(txtHost.Text).AddressList[0], 11984);

Byte[] sendBytes-Encoding.ASCII.GetBytes(txtMsg.Text);

client.Send(sendBytes, sendBytes.Length);

}

}

catch (Exception ex) {

MessageBox.Show(ex.Message);

}

}

Testing

The following pictures are demonstration the two identical application running in different network hosts. The two applications are sent data to each other, notice that the one is using the hostname to find the other and the other one is using the IP address.

image1.jpg

image3.png

Remarks:

· Two applications cannot be tested on the same machine while listening on the same port, the port of the application for listening should be set manually but the well-known feature will be lost.

· The thread that we start uses an infinite loop and thus that thread never stops, I have to put a lot of programmatically effort to stop that thread, therefore, killing the process manually is a better option at the point.

Bibliography-References

ACSC424 Network Application Programming_lec_5 - UDP socket programming

1