-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpySeFi_Server.py
More file actions
55 lines (42 loc) · 1013 Bytes
/
pySeFi_Server.py
File metadata and controls
55 lines (42 loc) · 1013 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
|Python File Sender|
programa simple para enviar archivos
"""
import socket
def conectar(s):
con, addr = s.accept()
print(addr, "se conecto")
return con
def recibir(con):
datos = con.recv(1024)
filename = datos.decode()
file = open(filename, 'wb')
while True:
fileData = con.recv(512)
if not fileData:
break
file.write(fileData)
file.close()
print('archivo recibido -> {}'.format(filename))
def cerrar(con, s):
con.close()
s.close()
def main():
print(banner()+'\n\t\tby developmentMen')
s = socket.socket()
s.bind((socket.gethostname(), 6333))
s.listen()
print("servidor esperando --> {}".format(socket.gethostbyname(socket.gethostname())))
con = conectar(s)
#try:
recibir(con)
#except :
#pass
cerrar(con, s)
def banner():
ban=" ___ ___ ___ _ \n | _ \_ _/ __| ___| __(_)\n | _/ || \__ \/ -_) _|| |\n |_| \_, |___/\___|_| |_|\n |__/ "
return ban
if __name__=='__main__':
main()