2

I have a small application that spawns a number of ports (300 to be exact). When it spawns a socket it uses:

# when someone connects via socketlistener, do some stuff
class SocketListener((SocketServer.BaseRequestHandler)):
      print "Do some stuff"

Is there a way to tell within SocketListener what port someone connected on?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985

1 Answers1

2

It depends how you instantiate the class that inherits BaseRequestHandler, but this might help:

class SocketListener((SocketServer.BaseRequestHandler)):
    def handle(self):
        print self.server.server_name, self.server.server_port
Tisho
  • 8,320
  • 6
  • 44
  • 52