2 Replies - 210 Views - Last Post: 29 May 2019 - 06:44 AM Rate Topic: **--- 2 Votes

#1 massarraa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 29-May 19

SocketException: connection was aborted by your host computer software

Posted 29 May 2019 - 05:07 AM

I have written typical TCP/IP program (a c# client on unity3d and a python server on raspberry).the client sends commands to the raspberry through buttons, and the server responds to it by exciting relays. When i run the server and connect the client to it for the first time, everything is doing well, but if i close connection on the client and then i reconnect it to the server and click on any button, the command is sent but the connection is closed on the server and i couldn't send another command only if i re-run the server. And it shows that error message on unity :" SocketException: connection was aborted by your host computer software" Anyone could help me to solve that problem?

Is This A Good Question/Topic? 0
  • +

Replies To: SocketException: connection was aborted by your host computer software

#2 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6962
  • View blog
  • Posts: 23,666
  • Joined: 05-May 12

Re: SocketException: connection was aborted by your host computer software

Posted 29 May 2019 - 06:11 AM

Without seeing the server code, it would be really hard to diagnose things. It sounds like the server doesn't know how to deal with dropped client connections.

If you'll be posting the Python server code, be sure to hit the Report button so that this thread gets moved to the Python forum instead of staying here in the C# forum.
Was This Post Helpful? 0
  • +
  • -

#3 massarraa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 29-May 19

Re: SocketException: connection was aborted by your host computer software

Posted 29 May 2019 - 06:44 AM

this is my server code:
import socket
import RPi.GPIO as GPIO
def sending_and_receiving() :
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(3, GPIO.OUT, initial=1)
    GPIO.setup(5, GPIO.OUT, initial=1)
    GPIO.setup(7, GPIO.OUT, initial=1)
    GPIO.setup(8, GPIO.OUT, initial=1)
    GPIO.setup(15, GPIO.OUT, initial=1)
    GPIO.setup(16, GPIO.OUT, initial=1)
    GPIO.setup(12, GPIO.OUT, initial=1)
    GPIO.setup(13, GPIO.OUT, initial=1)
    outputs_list=(3,5,7,8,15,16,12,13)
    GPIO.setwarnings(False)
    s= socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    print('socket created')
    port=2001
    s.bind(('192.168.8.101', port))
    print('socket binded to port')
    s.listen(1)
    print('socket listening...')
    while 1 :
        print('wait for connection')
        c, addr= s.accept()
        try:
            while 1 :
                print("\ngot connection from ", addr)
                output="Hello"
                c.sendall (output.encode('utf-8'))
                de=c.recv(1024).decode("utf-8")
                var= int(de, 10)
                if var:
                    print('Getting data from the unity:',var)
                    if var== 1:
                               GPIO.output(3, 0)
                    elif var==2 :
                               GPIO.output(5, 0)
                    elif var==3 :
                               GPIO.output(7, 0)
                    elif var==4 :
                               GPIO.output(8, 0)
                    elif var==5 :
                               GPIO.output(15, 0)
                    elif var==6 :
                               GPIO.output(16, 0)
                    elif var==7 :
                               GPIO.output(12, 0)
                    elif var==8 :
                               GPIO.output(13, 0)
                    else :
                               GPIO.output(outputs_list, 1)
                   
                                   
                               
                               
                    #test() ;
                #else:
                    #break
        except:
                    c.close()
                    print('connection closed')
                    #GPIO.output(3, False)
                    #GPIO.output(5, False)
                    GPIO.cleanup()
                    
sending_and_receiving()
:code:

This post has been edited by modi123_1: 29 May 2019 - 06:53 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1