What is the difference between socket programming and Http programming? can anyone help please?
相关问题
- Multiple sockets for clients to connect to
- Drakma and Dexador both fails at USocket call whil
- difference between file descriptor and socket file
- Can we create a Silverlight Socket Server ONLY usi
- How do I get the client name from a socket in Java
相关文章
- socket() returns 0 in C client server application
- Passing extra metadata to a RequestHandler using p
- How do I get the external IP of a socket in Python
- Native hooking in Android Client
- Is zeroing out the “sockaddr_in” structure necessa
- Does the TCPServer + BaseRequestHandler in Python&
- Is it possible to convert between Socket and TcpCl
- boost:asio IPv4 address and UDP comms
With HTTP you use high-level HTTP protocol(that works on top of a socket). It's session-less which means you send text request like
GET google.com
and receive text or binary data in return, after that connection is closed(in HTTP 1.1 persistent connections are available)MSDN example:
With sockets you go on the level lower and actually control the connection and send/receive raw bytes.
Example:
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.
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 theHttpWebRequest
classes.HTTP programming or HTTP request is used for loosely coupling and platform-neutral language technology communication where as socket programming is used where system has language specification protocol