socket- a fake encounter programmer

1. look ignorant than

Today they happened to see socket, socket a little bit of simple concepts, know network programming, client and server communications, but not too well, you just found the next, tens of millions of records, just read a few points to open page, socket with network programming is also bundled together, and found the next, but also introduces a lot.

Casually points to open an article, the beginning of the introduction to " socket socket is that most programmers are very familiar with the concept, it is the basis of computer network programming, TCP / UDP messaging depends on it . Most programmers are familiar a? bit stupid than the developed done for 10 years, had never used soket how programming ah, looked at the code or demo soon be able to run up, it may have been useless to the hair before? use What place? Am I a fake programmer?'ve been doing business development projects, it did not seem to use ah, do not do fake items? a little cynicism.

2. crazy mode

As a java development veterans (i'm software Pharaoh), start searching java socket programming, run a few demo, also lacks ah, I still doubt that, people say most of the developers are very familiar with, as what we did with the previous project ah? Where soket programming used to go? Java is not in the framework of the spring or web container tomcat, weblogic and other good package, with do not know it?

3. little prospect of a solution

View Profile aside while to realize, from the search begins: "Why use socket", "Network Programming", "java network programming", "java socket programming" to see "Enterprise Application socket" look of ignorant than until " springboot socket "," websocket "," http and websoket "was probably understand how it happens. .

4. initial introduction

java socket programming staff have not used normal, if there are false programmers like me, how not previously used socket programming, do not panic of a force, no doubt life is very normal (peat), plans to start preliminary presentation under the concept, the subsequent free, with code demo again, to the next.

4.1 socket programming

Socket是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口。在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协议族隐藏在Socket接口后面,对用户来说,一组简单的接口就是全部,让Socket去组织数据,以符合指定的协议。i'm 软件老王

socket is a big concept introduced a word or two is not clear, first there is the concept of it, there are many places to use, there are many languages, client / server of c / s mode, in particular, multi-purpose, socket called in the windows Windows Sockets, you involved on the desktop to communicate, such as qq, cool dog, browser, table games ah so on it, socket communication is the basis of computer network programming, communication on the Internet without it. Realize there are many languages ​​C, C ++ ,. net, python, java and so on it, has a corresponding implementation package. i'm Pharaoh software

4.2 java socket

java related packages of socket again java.net. * below, but the local socket used in java, in fact, not much.

JAVA2平台包括:J2SE(Java2 Standard Edtion)标准版、J2EE(Java2 Enterprise Edition)企业版、J2ME(Java2 Micro Edition)微缩版。
J2SE:包括构成Java语言核心的类。比如数据库连接、接口定义、网络编程类。
J2EE:包括了J2SE中的类,并且还包括了开发企业级应用的类。比如EJB、JSP等。i'm 软件老王
J2ME:包含了J2SE中的一部分类,主要用于手机软件开发。i'm 软件老王

J2SE and J2ME with fewer people (originally wanted to write basic no one used, words can not say it is full), the majority of the current java application is based on B / S mode, that is, the browser and the server, using a browser the http protocol.

java package provides a socket operation, but the scene used very little.

4.3 HTTP connection

HTTP protocol Hypertext Transfer Protocol (Hypertext Transfer Protocol), is the basis for Web networking, mobile phone network is one of the commonly used protocol, HTTP protocol is an application built on top of TCP protocol.
HTTP connection most notable feature is the client sends the server needs to send back a response for each request, after the request, will take the initiative to release the connection. From the establishment of the connection to close the connection process is called "a connection."
(1) in the HTTP 1.0 client requests each time required to establish a separate connection, after processing this request, releases the connection automatically.
(2) you can process HTTP 1.1 in a plurality of connection requests, and multiple requests overlap, without waiting for the next request after the end of a transmission request.
Because at the end of each HTTP request will take the initiative to release the connection, thus HTTP connection is a "short connection" to remain online client program, the need to constantly initiates a connection request to the server. The usual practice is not necessary to obtain any data for real time, the client also maintains a fixed period of time to send a request to "stay connected" to the server every server to the client after receiving the reply request, indicates that the client knows " online. " If the server can not long received the client's request, the client is considered "offline", if the client can not receive a response time of the server, the network is considered to have been disconnected.

4.4 WebSocket

HTTP connection using the "request - response" approach, not only in the need to establish a connection request, and the need for client makes a request to the server, the server can return data, HTTP protocol server can not take the initiative to push information to the client this way nothing bad, from the network in terms of safety, to avoid unnecessary harassment on the server side,
but this way the requested features, doomed if the server has a continuous state of change, the client should know very troublesome. We can only use the "poll": from time to time, it sends a query to understand the server has no new information, inefficient polling, is a waste of resources (because it must constantly connected, or HTTP connection is always open, i 'm Wang software).
WebSocket is produced in this context, WebSocket protocol in 2008, was born in 2011 as an international standard. All browsers already support. Its biggest feature is that the server can take the initiative to push information to the client, the client can also send information to the server, it is a true two-way dialogue equality, is a technology push server, which is a supplement of http.

4.5 preliminary conclusions

Websocket similar to Java in the HTTP protocol is a protocol only if there are false programmer like me (i'm software Pharaoh), how not used before, do not panic a force, in fact nothing, many or most enterprise Java applications is less than socket protocol, 05/06 after the company upgraded the previous CS mode to B / S model, it is based on the HTTP protocol.


I'm "Software Pharaoh," I felt that if I may, to focus the next chant, subsequent updates seconds to know! Welcome forum, No. namesake public message exchange!

Guess you like

Origin www.cnblogs.com/ruanjianlaowang/p/11427718.html