Hi all
In college at the moment we are covering sockets in python how to open them and communicate through them etc. I am doing awesome up to the point where I am told to keep the socket open until quite request is sent. This for me is proving a little hard to do and no matter what I can't find help online as most of them are talking over my head.

Please find my code which no matter what shuts the socket down.

#Server import
import socket as sk

request = False

#create server socket
serSock = sk.socket(sk.AF_INET, sk.SOCK_STREAM)

#Request the socket you want to open.
requSock = input('Please add socket you want to open ')
requSock1 = int(requSock)

#bind to address which includes the port
serSock.bind(('', requSock1)) # Leaving the address field blank allows access from all computers
print ('Reserved port ', requSock1)

if request != True:

    # listening to the address
    serSock.listen(1)
    print ('Listening to port ', requSock)

    #wait and accept a connectionfrom client
    connection,  clAdr = serSock.accept()
    print('Received connection from ', clAdr)

    #recieve data from client
    datIn = connection.recv(1024) #Number in recv is package size
    mesIn = datIn.decode()
    print('Received from client: ',mesIn)

    #send back
    datOut = mesIn.encode()
    connection.send(datOut)

    #finish = input(' Are you finished y/n')

    #if finish == 'y':

        #request = True

#shut and close socket
serSock.shutdown(sk.SHUT_RDWR)
serSock.close()
print('Sending shutdown and close signal to socket ')

Any help would be awesome thanks Matthew