Add utils.

This commit is contained in:
Mikaël Ates 2016-03-10 07:08:02 +01:00
parent ffc5103dac
commit 9a6edf0020
1 changed files with 19 additions and 0 deletions

19
utils.py Normal file
View File

@ -0,0 +1,19 @@
import socket
from datetime import datetime
from time import sleep
def unix_time(dt):
epoch = datetime.utcfromtimestamp(0)
delta = dt - epoch
return delta.total_seconds()
def netcat(hostname, port, content):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((hostname, port))
s.sendall(content)
sleep(0.005)
s.shutdown(socket.SHUT_WR)
s.close()