Socket server | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Socket server

As in socket it will set the address on ip, instead of on host(url)

11th Aug 2017, 5:51 AM
Kreez
Kreez - avatar
3 Answers
+ 1
import socket # get name host = socket.gethostname() port = 9999 # bind to the port serversocket.bind ((host, port)) # queue up to 5 requests serversocket.listen(5) while True: # establish a connection clientsocket,addr = serversocket.accept() print ("Got a connection from %s" % str(addr)) msg = 'Thank you for connecting'+ "\r\n" clientsocket.send (msg.encode('ascii')) clientsocket.close()
11th Aug 2017, 7:27 AM
Given
Given - avatar
0
i writed socket.socket.bind(("my ip",4830)) error Errno 99 Cannot assign requested address
11th Aug 2017, 5:54 AM
Kreez
Kreez - avatar
0
nono. I want to use ip instead of host
11th Aug 2017, 8:04 AM
Kreez
Kreez - avatar