forked from RomaniukVadim/hack_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkServer.py
More file actions
34 lines (27 loc) · 782 Bytes
/
NetworkServer.py
File metadata and controls
34 lines (27 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/python3
__author__ = 'kilroy'
# (c) 2014, WasHere Consulting, Inc.
# Written for Infinite Skills
import socket
size = 512
host = ''
port = 9898
# family = Internet, type = stream socket means TCP
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# we have a socket, we need to bind to an IP address and port
# to have a place to listen on
sock.bind((host, port))
sock.listen(5)
# we can store information about the other end
# once we accept the connection attempt
c, addr = sock.accept()
data = c.recv(size)
if data:
f = open("storage.dat", '+w')
print("connection from: ", addr[0])
f.write(addr[0])
f.write(":")
f.write(data.decode("utf-8"))
f.close()
sock.close()