f5

来源:互联网 发布:手机发布淘宝宝贝 编辑:程序博客网 时间:2024/04/27 13:23
def create_game():
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) 
    local_ip = get_local_ip()
    #local_ip = "127.0.0.1"
    s.bind((local_ip,9325))
    s.listen(5)
    while True:
        con,addr = s.accept()
        f = open("hello.txt",'w')
        f.write("accept()")
        f.close()
        break
    return con,addr
   
def join_game():
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    local_ip = get_local_ip()
    #local_ip = "127.0.0.1"
    print local_ip
    s.connect((local_ip,9325))
    return s
def logger(filename,text):
    f = open(filename,'w')
    f.write(text)
    f.close()