This repository has been archived on 2023-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
ACMS/src/Common/socketCommands.py

34 lines
585 B
Python

#!/usr/bin/env python3.5
# -*- coding: utf-8 -*-
"""
Basic send & receive functions for socket usage.
"""
__authors__ = "HorlogeSkynet, CaumartinYann"
__copyright__ = "Copyright 2017, ACMS"
__license__ = "GPLv3"
__status__ = "Production"
__date__ = "03/03/2017"
# Our buffer length for data sent and received
BUFFER_SIZE = 4096
def sendData(connection, data, errHandler, *args):
try:
connection.send(data.encode())
except:
errHandler(*args)
def recvData(connection, errHandler, *args):
try:
return connection.recv(BUFFER_SIZE).decode()
except:
errHandler(*args)