I have a server socket on Python and the client on React. I want to transmit plain text. But the client does not connect to the server socket. What I'm doing wrong ?. I've tried whit a client socket on python and It works but, not in this way. I appreciate any help
Server (Python)
import socket
s = socket.socket()
s.bind(('localhost', 8000))
s.listen(5)
while True:
con, addr = s.accept()
print("New connection")
print(addr)
con.send("Message")
con.close()
Client (React)
import io from "socket.io-client";
componentDidMount() {
const socket = io("localhost:8000", {
transports: ["websocket"],
reconnection: true,
});
socket.on("connection", () => {
this.setState({ isConnected: true });
});
socket.emit("Message to server", (data) => {
console.log(data);
});
}