JuliaLozova / messenger

0 stars 0 forks source link

Could doesServerExist() be an option.... #4

Open JuliaLozova opened 7 years ago

JuliaLozova commented 7 years ago

def messengerServer():
    print('starting up on {} port {}'.format(*server_address))
    s.setblocking(0)
    s.bind((HOST, PORT))
    s.listen(5) 
    print "Welcome to Jchat! You can now start sending messages!"
    sys.stdout.write('[Me] '); sys.stdout.flush()
    makeConnection = 1
    manyFunctions(makeConnection)

def messengerClient():
    s.connect((HOST, PORT))
    connected = s.connect((HOST, PORT))
    #print type(connected)
    message_queues[s] = queue.Queue()
    print "Welcome to Jchat! You can now start sending messages!"
    sys.stdout.write('[Me] '); sys.stdout.flush()
    makeConnection = 0
    manyFunctions(makeConnection)

def doesServerExist():
    if connected == 0:
    #print connected
        messengerServer()
    else:
        messengerClient()

if __name__ == "__main__":
    doesServerExist() ```
JuliaLozova commented 7 years ago

Currently I get a global variable error, but if I fix that, could this be a viable option.