In short, the reason you got that error is that the client program tried to connect to port 8080, but there was no program listening for new connections on that port.
For two programs to communicate using sockets, one program must start listening for connections on a port, and another program must try to connect to the same port afterwards. Usually the program that listens for connections on a port is called the "server", and the program that attempts to make a connection is the "client".
So, in order for the example code to work, you have to run the server program first, and then the client program.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence