While I may not be well-versed in Javascript, I do have some instincts that might offer assistance without delving into your C Client specifics.
UTF-8
To begin with, the absence of UTF-8 encoding in your messages may not necessarily be the cause of the error you're facing. It's challenging to propose a fix without understanding the nature of the data being transmitted. This appears to be a straightforward implementation, and it's likely that your data consists of standard ASCII characters. These characters can be directly mapped to UTF-8. If you're working with encoded data other than this, then investigating the intricacies of UTF-8 encoding/decoding is essential. Referencing this resource could provide a good starting point.
Are there any additional factors at play?
Error : Error: read ECONNRESET
The occurrence of ECONNRESET typically indicates an unexpected closure on the opposite end of the TCP connection or termination of the connection while data remains pending. The server seems to trigger this error while the client exits normally. It's plausible that an application-protocol error is causing this issue. Review your code meticulously, considering if there's behavior prompting the client to close its end of the connection prematurely. One possible scenario is utilizing non-blocking sockets. With a non-blocking socket, calling write()/send() followed by an immediate exit could sever the connection before the server reads the data.
It's less probable that the problem stems from UTF-8 encoding (or lack thereof) and more probable that the client is responsible for resetting the connection. Pinpointing why the client closes its end is tricky sans any code insight. Examine both client and server codes step by step, evaluating the connection status at each key function call. Should neither UTF-8 nor TCP issues be at fault, consider exploring JS-specific matters. In such instances, referring to this thread would be beneficial. Given the simplicity of your setup, underlying framework complexities are unlikely.
Network programming necessitates patience and careful consideration. Enhance your grasp on TCP connections and thoroughly understand how your programs operate before assuming a data encoding dilemma.