mirror of https://github.com/kurisufriend/manager
parent
be1942155f
commit
f8e144031e
@ -0,0 +1,6 @@ |
||||
import socket |
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
||||
s.connect(("192.168.1.2", 1337)) |
||||
message = "ohayou~" |
||||
s.sendall(message.encode("ASCII")) |
||||
s.close() |
@ -0,0 +1,12 @@ |
||||
import socket |
||||
class client: |
||||
def __init__(self, sock_, address_): |
||||
self.sock = sock_ |
||||
self.address = address_ |
||||
def __del__(self): |
||||
self.sock.close() |
||||
def run(self): |
||||
while True: |
||||
data = self.sock.recv(1024) |
||||
if not data: continue |
||||
print(self.address, ":", data.decode("ASCII")) |
@ -0,0 +1,4 @@ |
||||
import server |
||||
|
||||
s = server.server("192.168.1.2", 1337) |
||||
s.run() |
@ -0,0 +1,23 @@ |
||||
import socket |
||||
import client |
||||
import threading |
||||
|
||||
class server: |
||||
def __init__(self, address, port): |
||||
self.clients = [] |
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
||||
self.sock.bind((address, port)) |
||||
self.sock.listen() |
||||
def __del__(self): |
||||
for c in self.clients: |
||||
del c |
||||
def run(self): |
||||
while True: |
||||
(client_sock, address) = self.sock.accept() |
||||
c = client.client(client_sock, address) |
||||
|
||||
self.clients.append(c) |
||||
print("added client:", address) |
||||
|
||||
t = threading.Thread(target=c.run, args=()) |
||||
t.start() |
@ -0,0 +1,3 @@ |
||||
class task: |
||||
def __init__(self): |
||||
pass |
Loading…
Reference in new issue