X-Git-Url: https://mudpy.org/gitweb?a=blobdiff_plain;f=lib%2Fmuff%2Fmuffsock.py;fp=lib%2Fmuff%2Fmuffsock.py;h=0000000000000000000000000000000000000000;hb=fecd4c0fc49593052697b8cf199603cf1fac2b61;hp=fe4706190282e04d010a82f658bbbccdd6d6a687;hpb=724736a86ae223448f90a6d3a15adacd035feaa5;p=mudpy.git diff --git a/lib/muff/muffsock.py b/lib/muff/muffsock.py deleted file mode 100644 index fe47061..0000000 --- a/lib/muff/muffsock.py +++ /dev/null @@ -1,66 +0,0 @@ -"""Socket objects for the MUFF Engine""" - -# Copyright (c) 2005 mudpy, Jeremy Stanley , all rights reserved. -# Licensed per terms in the LICENSE file distributed with this software. - -# need socket.socket for new connection objects and the server's listener -import socket - -# hack to load all modules in the muff package -import muff -for module in muff.__all__: - exec("import " + module) - -def check_for_connection(newsocket): - """Check for a waiting connection and return a new user object.""" - - # try to accept a new connection - try: - connection, address = newsocket.accept() - except: - return None - - # note that we got one - muffmisc.log("Connection from " + address[0]) - - # disable blocking so we can proceed whether or not we can send/receive - connection.setblocking(0) - - # create a new user object - user = muffuser.User() - - # associate this connection with it - user.connection = connection - - # set the user's ipa from the connection's ipa - user.address = address[0] - - # return the new user object - return user - -def initialize_server_socket(): - """Create and open the listening socket.""" - - # create a new ipv4 stream-type socket object - newsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - # set the socket options to allow existing open ones to be reused - # (fixes a bug where the server can't bind for a minute when restarting - # on linux systems) - newsocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - - # bind the socket to to our desired server ipa and port - newsocket.bind((muffconf.get("network", "host"), muffconf.getint("network", "port"))) - - # disable blocking so we can proceed whether or not we can send/receive - newsocket.setblocking(0) - - # start listening on the socket - newsocket.listen(1) - - # note that we're now ready for user connections - muffmisc.log("Waiting for connection(s)...") - - # store this in a globally-accessible place - muffvars.newsocket = newsocket -