Respawn after connection close

This commit is contained in:
Yanis Boucherk 2021-03-18 09:39:05 +01:00 committed by GitHub
parent 154f38f2c0
commit bc5a551e71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 36 deletions

View File

@ -1,6 +1,5 @@
import socket, hashlib
# Global variables
soc = socket.socket()
username = "user" # Edit this to your username, mind the quotes
pool_address = "51.15.127.80"
pool_port = 2811
@ -8,6 +7,8 @@ pool_port = 2811
print("Starting 3DS Miner, you probably will get Output on an error.")
while True:
try:
soc = socket.socket()
soc.connect((str(pool_address), int(pool_port))) # Connect to the server
server_version = soc.recv(3).decode() # Get server version
print("Server is on version", server_version)
@ -18,7 +19,7 @@ while True:
# Don't mind the "ESP32" for now since it is in an early state
job = soc.recv(87).decode() # Get work from pool
job = soc.recv(100).decode() # Get work from pool
job = job.split(",") # Split received data to job (job and difficulty)
difficulty = job[2]
for result in range(
@ -34,12 +35,6 @@ while True:
feedback = soc.recv(1024).decode() # Get feedback about the result
print(feedback)
except:
while True:
try:
soc.close()
soc = socket.socket()
soc.connect((str(pool_address), int(pool_port))) # Connect to the server
break
except:
pass
else:
break