C#, 284 283 282 278 274274 254 bytes
class A{static int Main(string[]a){var b=new System.Net.Sockets.TcpListener(int.Parse(a[0]));b.Start();for(;;)using({var c=b.AcceptTcpClient())using(var;var d=newd=c.Client.LocalEndPoint.Serialize();new System.IO.StreamWriter(c.GetStream())){var e=c.Client.LocalEndPoint.Serialize();d.WriteLine(e[4]+e[5]+e[6]+e[7]d[4]+d[5]+d[6]+d[7]);}}} Classic example of a basic C# TCP server. Testing:
Terminal 1:
$ ./Q76379.exe 1029 Terminal 2:
$ telnet localhost 1029 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 128 Connection closed by foreign host. Firefox:
