Initial Commit
This commit is contained in:
33
Server/server.py
Normal file
33
Server/server.py
Normal file
@ -0,0 +1,33 @@
|
||||
from SMTPServer import SMTPServer
|
||||
|
||||
server_host = "0.0.0.0"
|
||||
server_port = 50000
|
||||
|
||||
start_attempts = 0
|
||||
max_start_attempts = 3
|
||||
server_started = False
|
||||
quit_flag = False
|
||||
|
||||
if __name__ == "__main__":
|
||||
while not quit_flag:
|
||||
print(f"Starting the server on {server_host}:{server_port}")
|
||||
|
||||
smtp_server = SMTPServer(server_host, server_port)
|
||||
|
||||
# Give the server 3 attempts to start, otherwise exit the program
|
||||
if not server_started:
|
||||
server_started = smtp_server.start_server()
|
||||
start_attempts += 1
|
||||
|
||||
if server_started:
|
||||
# Open the server and start the main script loop
|
||||
smtp_server.open_server()
|
||||
if not smtp_server.active:
|
||||
quit_flag = True
|
||||
|
||||
else:
|
||||
if start_attempts == max_start_attempts:
|
||||
print("Could not start the server, Exiting...")
|
||||
quit_flag = True
|
||||
|
||||
print("Server Ended, Thank you.")
|
Reference in New Issue
Block a user