Allow setting socket options
This commit is contained in:
parent
c6752502d6
commit
4861357b88
|
@ -31,10 +31,11 @@ class serverThread(threading.Thread):
|
|||
pass
|
||||
|
||||
global makeServer
|
||||
def makeServer(host,port,https):
|
||||
def makeServer(host,port,https,sockOpts):
|
||||
print("Opening " +str(host)+ ":" +str(port)+ " (" +str(https)+ ") ...")
|
||||
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
serverSocket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
|
||||
for sockOpt in sockOpts:
|
||||
serverSocket.setsockopt(*sockOpt)
|
||||
serverSocket.bind((host,port))
|
||||
if https:
|
||||
proto = False
|
||||
|
@ -54,4 +55,4 @@ def makeServer(host,port,https):
|
|||
serverSocket.listen(65535)
|
||||
thread = serverThread(serverSocket,not (https == False))
|
||||
serverThreads.append(thread)
|
||||
thread.start()
|
||||
thread.start()
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
global servers
|
||||
servers = [
|
||||
# Host Port SSL Certificate
|
||||
("127.0.0.1", 61920, False),
|
||||
# ("127.0.0.1", 443, "localhost.pem")
|
||||
# Host Port SSL Certificate Socket Options
|
||||
("127.0.0.1", 61920, False, (
|
||||
(socket.SOL_SOCKET,socket.SO_REUSEADDR,1),
|
||||
(socket.IPPROTO_TCP,socket.TCP_NODELAY,1),
|
||||
(socket.IPPROTO_TCP,socket.IP_TOS,0x10) # IPTOS_LOWDELAY
|
||||
)
|
||||
),
|
||||
# ("127.0.0.1", 443, "localhost.pem", (
|
||||
# (socket.SOL_SOCKET,socket.SO_REUSEADDR,1),
|
||||
# (socket.IPPROTO_TCP,socket.TCP_NODELAY,1),
|
||||
# (socket.IPPROTO_TCP,socket.IP_TOS,0x10)
|
||||
# )
|
||||
# )
|
||||
]
|
||||
|
||||
global timeout
|
||||
|
@ -14,4 +24,4 @@ enableOutThread = False # Use a seperate thread for data output?
|
|||
global printExceptions
|
||||
printExceptions = False # Print exceptions as they happen, enable if you're developing
|
||||
global clientDebug
|
||||
clientDebug = False # Print how many clients and threads there are
|
||||
clientDebug = False # Print how many clients and threads there are
|
||||
|
|
Loading…
Reference in New Issue