Skip to main content
4 of 6
added 7 characters in body
LegionMammal978
  • 18.2k
  • 4
  • 25
  • 58

C#, 284 283 282 278 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()){var d=c.Client.LocalEndPoint.Serialize();var e=new System.IO.StreamWriter(c.GetStream());e.WriteLine(d[4]+d[5]+d[6]+d[7]);e.Flush();}}} 

Classic example of a basic C# TCP server. Don't run this for too many clients, as it leaks memory (I think). 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:

LegionMammal978
  • 18.2k
  • 4
  • 25
  • 58