I am trying to learn a little about socket programming and I have stumbled across TcpListener and TcpClient to use as I read they are slightly easier for beginners. The basic ji
If you know the name of the computer you want to connect to then you can find its IP quite easily with System.Net.DNS.
var ip = System.Net.Dns.GetHostEntry("JacksLaptop");
string ipString = ip.AddressList[0].ToString();
The IP you think you're using may not be the one in location 0 of that array so watch out for that.
Not quite sure what you mean by 'more dynamic way to encompass the changing ip'. Taking a guess for starters where you currently have:
TcpClient client = new TcpClient(<not sure>, port); //Unsure of IP to use.
You can run both client & server on the same machine and use the local loopback IP address:
IPAddress.Parse("127.0.0.1")
If they are running on different machines just replace 127.0.0.1 with whatever IP address the server is using (this assumes no NAT or firewalls in the way).
If you don't want to use IP addresses you could always use hostnames (these might be considered more 'dynamic') but this would require a suitably configured DNS setup (for local systems):
TcpClient client = new TcpClient("testMachine1", 1333);
It's great to learn socket programming. I am the developer of a network library, networkcomms.net, so should you also want to work backwards from a work example at the same time as learning yourself please checkout this wpf chat example.