Search code examples
csocketstcpfile-not-found

How does a tcp clients understands the server status codes


I am writing a socket programming in C to transfer files from Server to Client. where client sends a filename to server and the server reply with the file content. I couldn't understand how a server can intimate the client when the file asked by the client is not found in server side. Do i have to use any standard to reply a package to client, where the client can understand that as a FileNotFound ?


Solution

  • In your communication model, you are missing a layer of meta-data or control messages. at the minimum, you need to pass a status code before you return the file. I suggest that you implement a simplified version of HTTP client. you can find an example at:

    GitHub - reagent/http: Simple HTTP client in C