#Mumps, 114 Bytes
Golfed:
F{S J=0,I="|TCP|1" O I:(:1239) U I R K F K=1:1:4{S J=J+$P(##class(%SYSTEM.TCPDevice).PeerAddr(),".",K)} W J,! C I} Ungolfed:
F{ ; Loop over everything; S J=0, ; Initial IP segment total I="|TCP|1" ; TCP device O I:(:1239) ; Open the TCP device, port 1239. U I ; Use the TCP device R K ; Read from STDIN (anything) F K=1:1:4{ ; Iterate 1->4 in variable K S J=J+ ; Accumulate the following segments of the IP in var. J $P(##class(%SYSTEM.TCPDevice).PeerAddr(),".",K) ; Grab each piece of IPv4. } ; close the loop. W J,! ; Write the total w/newline out the TCP port C I ; close the TCP port to send. } ; end final loop This is the InterSystems Caché version of Mumps - if there's a version out there that can acquire the TCP address shorter than ##class(%SYSTEM.TCPDevice).PeerAddr() (as it's almost a 1/3 of the entire program) it might have a better chance against some of the other languages posted already... ;-)