I have just started to make a simple socket "chat" server where users connect to my server through telnet
. I was wondering how I could get the connected users IP address so that It would print out that users message like so:
IP address: "Hello"
This is the code I am using so far:
def broadcast(self, message):
for sessions in self.sessions:
sessions.push('>>' + message + '\r\n')
Thanks in advance, If you need any more information please ask.
EDIT:
A link to the entire program: http://pastebin.com/9vzuiLZe
<your-socket-instance>.getpeername()
will give you what you want