Hello Friends.
I have created the following program:
using System; using System.Net; using System.Net.Sockets; namespace OOSys { class Program { static void Main(string[] args) { Console.WriteLine("Please type something and press Enter:"); string userInputString; userInputString = Console.ReadLine(); Console.WriteLine("You typed: " + userInputString); Console.ReadLine(); // Stops concolse from disappearing. Socket socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("10.10.101.200"), 8221); socClient.Connect(remoteEP); try { byte[] byData = System.Text.Encoding.ASCII.GetBytes(userInputString); socClient.Send(byData); } catch (SocketException se) { Console.WriteLine(se); } } } }
|
By my logic, this program will connect to some server on Port number 8221. I would greatly appreciate it if you too could check that.
Now what I want to do is create another program that will "Listen" to the connections on that port, and receive the { userInputString } and display it. << However I am finding that difficult, I don't really know how I'd go about it.
I mean would I have to create a socket in the { Server.cs } too ? That's what I've decided to call my other program.
As always, I would greatly appreciate any help.
Thank You.