Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- getConnection();
- def getConnection():
- import socket;
- import time;
- host = socket.gethostbyname(socket.gethostname());
- port = 1024;
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as socket:
- socket.bind((host, port));
- socket.listen();
- print("---------------------------------------------------------------");
- print("[*] IP: {}.".format(host) + "\n[*] Porta: {}.".format(port));
- print("[*] Inicializando o servidor, por favor aguarde um instante...");
- print("---------------------------------------------------------------");
- time.sleep(3);
- print("[*] Servidor iniciado. Aguardando conexão...");
- print("---------------------------------------------------------------");
- while True:
- connection, address = socket.accept();
- print("[!] Conexão recebida de {}, com porta {}.".format(address[0], address[1]));
- print("---------------------------------------------------------------");
- if(__name__ == "__main__"):
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement