using System;namespace OOSys{class Product{private int ProductNo { get; set; }private string ProductName { get; set; }private string ProductType { get; set; }private double ProductPrice { get; set; }private string ProductMaker { get; set; }// Constructorpublic Product(int number, string name, string type, double price, string maker){ProductNo = number;ProductName = name;ProductType = type;ProductPrice = price;ProductMaker = maker;}}}
using System;using System.Net;using System.Net.Sockets;namespace OOSys{class Client{static void Main(string[] args){try{Product p = new Product(1, "CoD", "Shooter", 39.99, "UbiSoft");string userInputString;Console.WriteLine("This program will transfer a product to a server. \n");Console.WriteLine("Please type the number 1 followed by Enter to send the Product:");userInputString = Console.ReadLine();if (userInputString == "1"){Console.WriteLine("You Entered: " + userInputString);Console.WriteLine("Status: Sending Product ... ...");IPAddress[] ipAddress = Dns.GetHostAddresses("localhost");IPEndPoint remoteEP = new IPEndPoint(ipAddress[0], 8221);Socket socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);socClient.Bind(remoteEP);socClient.Connect(remoteEP); byte[] ProductData = System.Text.Encoding.ASCII.GetBytes(userInputString);socClient.Send(ProductData);socClient.Close();Console.ReadLine();}else{Console.WriteLine("Nothing will be sent !");}}catch (SocketException se){Console.WriteLine(se);}}}}