python scripting

I am trying to get some server side code on python working just a quick and dirty approach to it. This is just a prototype mind you

Currently there are two types of clients 1 desktop 1 mobile
upon first connection the desktop will send DesktopClient1
mobile will send MobileClient2

Currently I am getting this as an error and I don't know how to solve it

return getattr(self._sock,name)(*args)
socket.error: [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted

Open in new window

Below is the code

from socket import *
import thread, ssl
def handler(clientsocket, clientaddr):
    print "Accepted connection from: ", clientaddr
    while 1:
        data = clientsocket.recv(1024)
        i = 0 
        while (i <= 0):
            if data == "DesktopClient1":
                print data
                i = 1 + 1
                print 1
                print "Desktop Verified"
                clientsocket.send("Mobile Verified")
            elif data == "MobileClient2":
                print data
                i = 1 + 1
                print i
                print "Mobile Verified"
                clientsocket.send("Mobile Verified")
            if not data:
                print data
                msg = "You sent me: %s" % data
if __name__ == "__main__":
    host = 'localhost'
    port = 55567
    buf = 1024
    addr = (host, port)
    serversocket = socket(AF_INET, SOCK_STREAM)
    while 1:
        print "Server is listening for connections\n"
        clientsocket, clientaddr = serversocket.accept()
        thread.start_new_thread(handler, (clientsocket, clientaddr))

Open in new window

Josh RansomAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


    clientsocket = None

after the close.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Josh RansomAuthor Commented:
ahh yes that will work also. I figured out apparently I had a running duplicate server in the background taking the same port :)
Yes, that would break it too!  :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.