Reputation: 33
As part of the a class I wrote a code in python by importing the socket. Here is the code.
import socket
ms=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
ms.bind(('',1234))
ms.listen(5)
while True:
con, addr=ms.accept()
if con:
print("Someone made a request!")
con.close()
ms.close()
It has no errors but to access the server from the browser when i type the ip address in the browser. What to do, am I doing something wrong?
Upvotes: 2
Views: 2447
Reputation: 33
I changed the ms.bind(('',80))
and it works when i type my ip address in the address bar. So foolish of me not to check out the official documentation.
Upvotes: 1
Reputation: 5600
I recommend two ways to do that, first by changing the port address in your python code to 80. ms.bind(('',80))
will do the trick. This works because the default port for the browser to communicate is 80.
The second way is to type in your ip address and the port address in your browser address bar. For example 127.0.0.1:1234
replace 127.0.0.1 with your server ip address.
Upvotes: 2