Sockets Python disconnect client

1

I would like to have a specific client disconnected with a server command.

from socket import *



meuHost = ''


minhaPort = 50007


sockobj = socket(AF_INET, SOCK_STREAM)


sockobj.bind((meuHost, minhaPort))


sockobj.listen(5)


while True:
    conexão, endereço = sockobj.accept()                                       




    print('Server conectado por', endereço)

    while True:

        data = conexão.recv(1024)



        if not data: break

        conexão.send(b'Eco=>' + data)

If there is this "Accept" attribute, is there any way to "Kick" or disconnect a client from my server?

    
asked by anonymous 03.01.2017 / 01:41

1 answer

2

Have you simply tried conexão.close() ?

In fact, the documentation says that to close an instance you can also use the shutdown method before close :

conexão.shutdown()
conexão.close()
    
03.01.2017 / 12:06