python - How to display the information sent by socket in the browser
淡淡烟草味2017-05-18 10:56:56
0
2
946
The socket server built using the socket module, for example, listens to the local port 4399. I use a browser to connect, but the characters sent from the socket cannot be displayed. How to do this?
Because your port is not 80, the browser cannot use the http protocol to parse your request, because it does not know what 4399 is for, so if you want to use monitoring 4399, and use the browser to see the socket server sending message, you must construct the http message yourself
Regarding Python SOCKET, if you want the browser to see the data, then you must implement the HTTP protocol. Otherwise, how will the browser know what you are sending and how much data is there? About Python Socket HTTP, please see here https://github.com/thisforeda...
Because your port is not 80, the browser cannot use the http protocol to parse your request, because it does not know what 4399 is for, so if you want to use monitoring 4399, and use the browser to see the socket server sending message, you must construct the http message yourself
Regarding Python SOCKET, if you want the browser to see the data, then you must implement the HTTP protocol. Otherwise, how will the browser know what you are sending and how much data is there?
About Python Socket HTTP, please see here https://github.com/thisforeda...