I am trying to send Xbox One controller data over wifi from a host computer to the client. They are both running Linux and sometimes the code works flawlessly and others there is extreme lag between the two of them.
Here is the code I have right now for both the client and server, they are both connected to the same network which has no internet connection. Any help is greatly appreciated
Server.py
from inputs import get_gamepad
import socket
import time
HOST='192.168.1.198'
PORT=5002
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(2)
conn, addr=s.accept()
def gamepad():
    while 1:
        events = get_gamepad()
        for event in events:
            if(event.code == "ABS_Y"): #ABS_Z
                if (event.state > 9000):
                    percentage = float(float(event.state)/maxThrottle)
                    escValLeft.value = (((maxESC-minESC)/(maxThrottle-minThrottle))*float(event.state) + minESC)
                elif (event.state < -9000):
                    escValLeft.value = (((maxESCRev-minESCRev)/(maxThrottle-minThrottle))*float(abs(event.state)) + minESCRev+10)
                else:
                    escValLeft.value = minESC
            if(event.code == "ABS_RZ"):
                percentage = float(event.state/maxThrottle)
                escValRight.value = (((maxESC-minESC)/(maxThrottle-minThrottle))*float(event.state) + minESC)
def sendtoclient():
    while True:
        val = str(int(escValLeft.value))+","+str(int(escValRight.value))+sep
        print("Sending: " + val)
        conn.send(val)
client.py
import socket
HOST = '192.168.2.62'
PORT = 5002
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
dataL = 2550
dataR = 2550
def get_controller():
    global dataL
    global dataR
    while True:
        buf = ''
        hold = ''
        while len(buf) < 9:
            hold = s.recv(1)
            #print (hold)
            if hold == '[':
                pass
            elif hold == ']':
                pass
            else:
                buf += hold
        left,right = buf.split(',')
        dataL = int(left)
        dataR = int(right)
        print("L,R ",dataL,dataR)
