Skip to main content
added 2 characters in body
Source Link
sammko
  • 479
  • 3
  • 11

Python 3, 170 166166 147 bytes

from socket import*
s=socket(AF_INET,SOCK_STREAM)
s.bind(("",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%eval(a[0].replace(".","+"))),c.close()

Takes port on stdin, IPv4 only. Works on GNU/Linux (and, I assume, most other unices), which automatically expands "" to "0.0.0.0", not sure about Windows though.

Python 3, 170 166 bytes

from socket import*
s=socket(AF_INET,SOCK_STREAM)
s.bind(("",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%eval(a[0].replace(".","+"))),c.close()

Takes port on stdin, IPv4 only. Works on GNU/Linux (and, I assume, most other unices), which automatically expands "" to "0.0.0.0", not sure about Windows though.

Python 3, 170 166 147 bytes

from socket import*
s=socket()
s.bind(("",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%eval(a[0].replace(".","+"))),c.close()

Takes port on stdin, IPv4 only. Works on GNU/Linux (and, I assume, most other unices), which automatically expands "" to "0.0.0.0", not sure about Windows though.

added 35 characters in body
Source Link
sammko
  • 479
  • 3
  • 11

Python 3, 170 166 bytes

from socket import*
s=socket(AF_INET,SOCK_STREAM)
s.bind(("",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%eval(a[0].replace(".","+"))),c.close()

Takes port on stdin, IPv4 only. Works on GNU/Linux (and, I assume, most other unices), which automatically expands "" to "0.0.0.0", not sure about Windows though.

Python 3, 170 166 bytes

from socket import*
s=socket(AF_INET,SOCK_STREAM)
s.bind(("",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%eval(a[0].replace(".","+"))),c.close()

Takes port on stdin, IPv4 only. Works on GNU/Linux, which automatically expands "" to "0.0.0.0", not sure about Windows though.

Python 3, 170 166 bytes

from socket import*
s=socket(AF_INET,SOCK_STREAM)
s.bind(("",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%eval(a[0].replace(".","+"))),c.close()

Takes port on stdin, IPv4 only. Works on GNU/Linux (and, I assume, most other unices), which automatically expands "" to "0.0.0.0", not sure about Windows though.

save some bytes
Source Link
sammko
  • 479
  • 3
  • 11

Python 3, 177170 166 bytes

from socket import *import*
s=socket(AF_INET, SOCK_STREAM)
s.bind(("0.0.0.0""",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%sum(mapb"%d\n"%eval(int,a[0].splitreplace("."),"+"))),c.close()

Takes port on stdin, IPv4 only. Works on GNU/Linux, which automatically expands "" to "0.0.0.0", not sure about Windows though.

Python 3, 177 bytes

from socket import *
s=socket(AF_INET, SOCK_STREAM)
s.bind(("0.0.0.0",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%sum(map(int,a[0].split(".")))),c.close()

Takes port on stdin, IPv4 only.

Python 3, 170 166 bytes

from socket import*
s=socket(AF_INET,SOCK_STREAM)
s.bind(("",int(input())))
s.listen()
while 1:
 c,a=s.accept()
 c.send(b"%d\n"%eval(a[0].replace(".","+"))),c.close()

Takes port on stdin, IPv4 only. Works on GNU/Linux, which automatically expands "" to "0.0.0.0", not sure about Windows though.

Source Link
sammko
  • 479
  • 3
  • 11
Loading