difference between socket programming and Http programming

HTTP is an application protocol. It basically means that HTTP itself can’t be used to transport information to/from a remote end point. Instead it relies on an underlying protocol which in HTTP’s case is TCP.

enter image description here

You can read more about OSI layers if you are interested.

Sockets on the other hand are an API that most operating systems provide to be able to talk with the network. The socket API supports different protocols from the transport layer and down.

That means that if you would like to use TCP you use sockets. But you can also use sockets to communicate using HTTP, but then you have to decode/encode messages according to the HTTP specification (RFC2616). Since that can be a huge task for most developers we also got ready clients in our developer frameworks (like .NET), for instance the WebClient or the HttpWebRequest classes.

Leave a Comment