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/Server/socketCommands.py
2017-03-21 20:15:25 +01:00

37 lines
739 B
Python

#!/usr/bin/env python3.5
# -*- coding: utf-8 -*-
"""
Basic send & receive functions for socket usage.
"""
__authors__ = "HorlogeSkynet"
__copyright__ = "Copyright 2017, ACMS"
__license__ = "GPLv3"
__version__ = "0.1.0"
__status__ = "Development"
__date__ = "03/03/2017"
# Our buffer length for data sent and received
BUFFER_SIZE = 2048
def sendData(connection, data):
try:
connection.send(data.encode())
except:
print("An error occurred on the connection with a client, let\'s close its socket.")
connection.close()
def recvData(connection):
try:
return connection.recv(BUFFER_SIZE).decode().strip()
except:
print("An error occurred on the connection with a client, let\'s close its socket.")
connection.close()