why won't ethernet stay connected for more than a few hours?

Thanks for the reply, I've amended the code and I'll see how it runs overnight.