Created
March 12, 2016 05:13
-
-
Save tjt263/c0526f9c99966658bd56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import socket | |
import threading | |
bind_ip = "0.0.0.0" | |
bind_port = 9999 | |
# create a socket object | |
server = socket.socket(socket.AF_INET,socket.SOCK_STREAM) | |
# bind the server | |
server.bind((bind_ip,bind_port)) | |
server.listen(5) | |
print "[*] Listening on %s:%d" % (bind_ip,bind_port) | |
# client handling thread | |
def handle_client(client_socket): | |
# print data sent from client | |
request = client_socket.recv(1024) | |
print "Received: %s" % request | |
# send back a packet | |
client_socket.send("ACK!") | |
client_socket.close() | |
while True: | |
client,addr = server.accept() | |
print "[*] Accepted connection from: %s:%d" % (addr[0],addr[1]) | |
# spin up our client thread to handle incoming data | |
client_handler = threading.Thread(target=handle_client,args=(client,)) | |
client_handler.start() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment