Question
How to create a socket server which works over the web?
Is it simply a matter of correctly port forwarding, or will I have to buy a domain?
If I need a domain, is there any free way to do this?
Background
I am currently working on a basic IM project using Python 2.7.3 on Windows 7 (32 bit).
I want to send messages from the console to one of my friend's computers, using Python. This has been invaluable, but it only works within one machine.
In my attempts to send messages over the internet, I have tried using several strategies.
Since I will ultimately be using my Mac as the server, I have employed Port Map to port forward different ports. When I do this, Python responds by giving me this error message:
Enter the PORT number (1 - 10,000)4235 Socket Created Bind failed. Error Code : 49 Message Can't assign requested address Traceback (most recent call last): File "/Users/BigKids/Desktop/Server v3.py", line 18, in <module> sys.exit() SystemExitI have tried to simply put my IP address in as the port but it responds with an error message:
Please enter the host's IP >>> 68.***.***.128 Enter the PORT number (1 - 10,000)2432 Socket Created Bind failed. Error Code : 10049 Message The requested address is not valid in its context Traceback (most recent call last): File "D:\Python Programs\Sockets\First Project\Server v3.py", line 19, in <module> sys.exit() SystemExitHere is the necessary code:
HOST = raw_input("Please enter the host's IP >>> ") PORT = input ("Enter the PORT number (1 - 10,000)") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM ) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) print "Socket Created" try: s.bind((HOST, PORT)) except socket.error, msg: print "Bind failed. Error Code : " + str(msg[0]) + " Message " + str(msg[1]) sys.exit()