Are you planning to run a raw socket server on PythonAnywhere? Unfortunately that would not be something that we support -- you would not be able to route to it from the external Internet. If you wanted to connect from some other code running inside PythonAnywhere, it might work -- you could use this code to get the internal network address of the currently running process:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
print(s.getsockname()[0])
s.close()
...however, it could be different in different consoles, and may change from time to time.