I am new to working with networks and I am having trouble getting my Electron to connect to my python socket server using TCPClient. All the ports are set to accept on my linode server as well so there should be no need for port forwarding. Here’s a sample of my code:
Electron:
double i = 1;
int led = D7;
TCPClient client;
byte server[] = {000, 000, 000, 00}; // I put the IPv4 address of the server here
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
if (client.connect(server, 5555)){
digitalWrite(led, HIGH);
}
}
void loop() {
client.write(1, 500);
if(!client.connected()){
client.stop();
for(;;);
}
}
Python:
# create TCP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# bind socket to port
server_address = ('', 5555)
sock.bind(server_address)
sock.listen(1)
print('waiting for connection')
connection, client_address = sock.accept()
print('connected')
Currently it does not get past sock.accept()
. I am also running the python script in pycharm that’s SSH’ed into the server. I am not sure if that will affect anything.