#!-*- coding: utf-8 -*-
"""
Module for diffent connections.

:author: Stefan Lehmann
:email: stefan.st.lehmann@gmail.com

"""
from serial import Serial
import socket


class Connection:
    pass


class SerialConnection(Connection):
    def __init__(self, *args, **kwargs):
        super().__init__()
        self.serial = Serial(*args, **kwargs)

    def connect(self):
        self.serial.open()

    def disconnect(self):
        self.serial.close()

    def read(self, size=1):
        return self.serial.read(size)

    def write(data):
        return self.serial.write(data)


class SocketConnection(Connection):
    def __init__(self):
        super().__init__()
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    def connect(self, host=None, port=None):
        self.socket.connect((host, port))

@@ -459,19 +459,19 @@
 def 
-rea
+sen
 d(self, 
 size
@@ -470,14 +470,12 @@
 lf, 
-size=1
+data
 ):%0A 
@@ -504,17 +504,18 @@
 ial.
-read(size
+write(data
 )%0A%0A 
@@ -521,26 +521,36 @@
     def 
-write(data
+receive(self, size=1
 ):%0A     
@@ -571,26 +571,25 @@
 .serial.
-write(data
+read(size
 )%0A%0A%0Aclas
@@ -831,8 +831,202 @@
  port))%0A
+%0A    def disconnect(self):%0A        self.socket.close()%0A%0A    def send(self, data: bytes):%0A        return self.socket.send(bytes)%0A%0A    def receive(self):%0A        return self.socket.recvfrom(4096)%0A

rename read, write to send, receive