https://kotlinlang.org logo
#announcements
Title
# announcements
k

Kroppeb

08/31/2019, 3:56 PM
How can I make a simple tcp socket listener? The following python code does the job
Copy code
python
import socket

IP = "127.0.0.1"
PORT = 25565

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_STREAM)
sock.bind((IP, PORT))
sock.listen(1)
conn, addr = sock.accept()
try:
	while True:
		data = conn.recv(1024)
		if not data: break
		print(*(hex(i)[2:].rjust(2,'0') for i in data))
finally:
	conn.close()
but I can't seem to find an easy solution in kotlin
d

Dominaezzz

08/31/2019, 4:00 PM
Consider using ktor. There's a channel too, #ktor .
k

Kroppeb

08/31/2019, 4:17 PM
Thanks
7 Views