Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Python // C # - SOCKET connection is constantly interrupted
#1
Hello experts,


I'm new to the world of programming and I've already made a socket connection to C # on a Raspberry Pi (Python).

The software controls a servomotor. After a while, under the surface of the connection and the Raspberry Pi did not send commands to the servomotor because I believe the socket connection was broken.
Does anyone know a solution to my code?
import socket
from Handler import Handler
import time
from Servo import Servo
def Server(serverSocket, port):
    handler = Handler(12, 50)        
    serverSocket.listen(1)
    i=0
    connect = 1
    try:
        while i == 0:
            clientSocket, addr = serverSocket.accept()
            i = 1
        while connect == 1: 
            data = clientSocket.recv(1024)
            request = handler.handleRequest(data)
            if not data:
                  break
            if request == "SSDN K0":        
                connect = 0
            
    except Exception as ex: 
        print(ex)
    
    Server(serverSocket, port)
    
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
port=1234
serverSocket.bind(('192.168.0.8',port))
Server(serverSocket, port)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  how to get your own ip using python (NO SOCKET:) ) julio2000 3 272 Mar-02-2020, 09:35 PM
Last Post: buran
  Python server(Django web site)/client(Python app) connection Junior_Pythoneer 5 736 Jul-05-2019, 05:41 PM
Last Post: noisefloor
  Multi connection socket server help! MuntyScruntfundle 0 657 Feb-19-2019, 12:03 PM
Last Post: MuntyScruntfundle
  For Xilinx EthernetLite LWIP:Need help in Python SOCKET Coding Saras 1 1,029 Oct-01-2018, 05:16 AM
Last Post: Saras
  Python Socket programming with packets sourabhjaiswal92 1 1,907 Sep-18-2018, 06:24 AM
Last Post: martingever
  Python socket : Error receive data quanglnh1993 1 5,916 Mar-14-2018, 11:59 AM
Last Post: avorane

Forum Jump:


Users browsing this thread: 1 Guest(s)