简体   繁体   中英

What application layer protocol is being used when using sockets?

When using web browsers, the application layer protocol being used is HTTP. Whereas I frequently use sockets to create a connection to a server and pass along strings, a frequently used example in Python could be

import socket

clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientsocket.connect(('localhost', 8089))
clientsocket.send('hello')

What application layer protocol is being used when sending the string 'hello' with this basic example?

No specific application layer protocol is used in your case. An application layer protocol is some kind of standard how messages are exchanged on top of TCP/UDP whatever transport layer. These standards are defined so that different implementations can interact with each other by just implementing the specific standard.

You can also use sockets without using a standardized application layer protocols but instead just make up what kind of messages you send by your own - and this is exactly what you did.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM