Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Sockets afterall ? and Why cant we use sockets instead of HTTP?

Are sockets just a connection between 2 machines?

And if sockets can be established why do we even use HTTP connection?

like image 330
Carbonizer Avatar asked Jan 22 '11 02:01

Carbonizer


2 Answers

Http is a protocol built on top of sockets.

When you use Http, you're using a higher level of abstraction on top of sockets. You're still using sockets.

It's kind of like saying "Why would you use a .xyz document when you could just use a file?"

like image 134
Reed Copsey Avatar answered Oct 26 '22 17:10

Reed Copsey


Lets say that socket is just a stream between 2 remote systems which uses TCP/IP or maybe UPD lower level protocols for transport data. And HTTP is the higher level protocol which specifies HOW systems are communicating.

Small example: air is a transport level for voice, but you need words (an upper level protocol) for communication with other ppl.

But better for you to read here: http://en.wikipedia.org/wiki/OSI_model

like image 37
Elalfer Avatar answered Oct 26 '22 15:10

Elalfer