Search code examples
httpnetwork-programmingtcp

Does TCP has Response code system like HTTP response


Pardon me for my ignorance

HTTP Response code has this format

1xx informational response – the request was received, continuing process
2xx successful – the request was successfully received, understood, and accepted
3xx redirection – further action needs to be taken in order to complete the request
4xx client error – the request contains bad syntax or cannot be fulfilled
5xx server error – the server failed to fulfil an apparently valid request

Does TCP has similar or any Response code system if yes how to access it ?


Solution

  • TCP is a transport layer protocol and does not understand application level semantics. That would be provided by an application layer protocol like HTTP.

    TCP is essentially a unix socket. So if you are looking for some kind of error codes, all the socket related error codes that your operating system gives you is what you should use. For example, Linux (POSIX) provides things like ENOENT, EIO, etc. For Linux see: https://github.com/torvalds/linux/blob/5bfc75d92efd494db37f5c4c173d3639d4772966/tools/include/uapi/asm-generic/errno-base.h