I’ve have a question concerning the socket class.
I want to send data from the zerynth device to a webserver (apache2).
I’m using the socket class to connect to the webserver, but I receive an error:
Trying to connect to webserver…
Server did not respond.
The first and last line are the output of two print statements. The error url point to the “s.send(…” code line. Therefore the socket is created and connected.
Just for background info, the device has a wifi connection up and running, and I do receive print data via an UDP stream for debugging.
That said, could it be an error because two sockets are open?
The code executed is:
myPrint(“Trying to connect to webserver…”)
s = socket.socket()
s.send(bytes(‘GET /page.php?a=’ + a + ‘&b=’ + str(b) + &c=’ + c + ’ HTTP/1.1\r\nHost: www.’ + name + ‘.com\r\n\r\n’, ‘utf8’))
sleep(1000) # Just wait a bit for the server responce
data = s.recv(500) # Check to server’s responce message
except Exception as e:
myPrint('ERROR: requests: ’ + str(e))
sleep(500) # Just wait a bit for the server responce
Can someone explain why this isn’t working. The documentation isn’t very clear on how to setup such a connection.