1

在代码中;

import socket
HOST = ''   #another short form for INADDDR_ANY, all available interfaces
PORT = 50010 #arbitrary non-priviledged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))

s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr

我收到一个错误

socket.error: [Errno 10013] An attempt was made to access a socket in a way forb
idden by its access permissions

错误指向 s.bind()。关于为什么会发生这种情况的任何线索?基本上,我不想每次对服务器代码进行一些更改时都更改端口号。

4

0 回答 0