CN1684413A - Dynamic realizing method of network communication - Google Patents

Dynamic realizing method of network communication Download PDF

Info

Publication number
CN1684413A
CN1684413A CN 200410031052 CN200410031052A CN1684413A CN 1684413 A CN1684413 A CN 1684413A CN 200410031052 CN200410031052 CN 200410031052 CN 200410031052 A CN200410031052 A CN 200410031052A CN 1684413 A CN1684413 A CN 1684413A
Authority
CN
China
Prior art keywords
data
client
server end
network service
implementation method
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN 200410031052
Other languages
Chinese (zh)
Inventor
刘文涵
宋建福
崔杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inventec Corp
Original Assignee
Inventec Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inventec Corp filed Critical Inventec Corp
Priority to CN 200410031052 priority Critical patent/CN1684413A/en
Publication of CN1684413A publication Critical patent/CN1684413A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Computer And Data Communications (AREA)

Abstract

This invention discloses a dynamic realization method for a network communication, which first of all sets up a connection between a server and a customer to generate a data packet dynamically based on the data form determined by the customer and sends the data packet to the server, which receives the packet and distributes related buffer zone in terms of the length of the packet to store the actual data in the packet in the buffer zone so as to realize dynamic data exchange between the server and the customer.

Description

The dynamic implementation method of network service
Technical field
The present invention relates to a kind of implementation method of network service, particularly relate to a kind of method of dynamic realization network service.
Background technology
At present, the method for carrying out network communication all is client (Client) and server end (Sever) to be set up corresponding socket (Socket) connect, thereby realizes the data communication of point-to-point (Point to point).Socket is the network application DLL (dynamic link library) that BSD UNIX provides, and it adopts the communication mechanism of client-server end, makes network user end and server end by connection and exchanges data between the Socket realization network.
The detailed process of utilizing Socket to carry out network communication at first starts for server, the Organization Chart of well-known server end as shown in Figure 1, main program 10 connects a plurality of threads, if N client-requested arranged, then set up N thread 20,30 (thread 1, thread N), 40 finish and withdraw from 50 operation by exiting command.Starting client sometime and server connects then.Server and client begin must set up a socket, server bands together socket and a public network address then, make socket be in a kind of passive preparation accepting state again, stipulate its request queue length simultaneously, server just can receive connection request afterwards.The client just can connect with server after setting up socket.After connecting foundation, just can transmit and receive data between client and the server by connection.
In this communication modes, the relation of client and server end is not symmetrical, the client socket that server end socket and delocalization are concrete, but state to be connected such as be in, monitoring state of network in real time.The socket of client must at first be described the socket of the server that it will connect, and points out the address and the port numbers of server end socket, just proposes connection request to the server end socket then.And communication each time all will be set up a communication interface, therefore can cause certain system resource waste, must define a Buffer fixed length, that memory space is enough big (buffer storage) in addition as the container that receives from the Client end data, and just there is the situation of the wasting of resources in the data capsule of fixed length itself.For the Buffer of fixed length, the process of withdrawing from be generally when the data value of reading be sky or data value 210 for-1 the time (as shown in Figure 2), just show that the data among the Stream (data flow) have run through, connect immediately and interrupt.The method that withdraws from like this lacks controllability, thereby makes the end read operation clear and definite inadequately.Adopt passive withdrawing mode simultaneously, also make the operation of client and server lack interactivity, brought operational inconvenience.
Summary of the invention
Technical problem to be solved by this invention provides a kind of dynamic implementation method of network service, solves the operation inconvenience of prior art, and resource and waste of time problem.
For achieving the above object, the invention provides a kind of dynamic implementation method of network service, be used to realize the dynamic data exchange of server end and client, its characteristics are, comprise the steps:
Create data channel according to the connection request of this client, set up being connected of this server end and this client;
This client specified data form, this data format comprises command word, data length and True Data;
This client dynamically generates packet according to this data format, and this packet is sent to server end;
This server end receives this packet, and according to this data length, distributes the buffering area of respective length; And
True Data in this packet is stored to this buffering area.
The dynamic implementation method of above-mentioned network service, its characteristics are, also comprise the quantity according to client, create the step of the thread of respective numbers.
The dynamic implementation method of above-mentioned network service, its characteristics be, after the described step that True Data is stored to this buffering area, also comprises the step of the request that continues to wait for client.
The dynamic implementation method of above-mentioned network service, its characteristics are, also comprise the request of withdrawing from according to this client, disconnect the step of connecting of this client and this server end.
The dynamic implementation method of above-mentioned network service, its characteristics be, described to withdraw from request be that command word in the data format is for exiting command.
The dynamic implementation method of above-mentioned network service, its characteristics are that described data format is command word and data queue.
The dynamic implementation method of above-mentioned network service, its characteristics are that described data queue comprises data item number and data length and True Data.
The dynamic implementation method of above-mentioned network service, its characteristics are that described data format also comprises command word length.
The dynamic implementation method of above-mentioned network service, its characteristics be, described this server end of setting up is set up this server end with being connected to of this client and is connected with the socket of this client.
The dynamic implementation method of above-mentioned network service, its characteristics are that described command word is that the user defines jointly at this server end and this client.
Technique effect of the present invention is:
The dynamic implementation method of the network service that the present invention carried, realized the process that dynamic package of client and server end are dynamically resolved, client can the Autonomous Control communication channel connection, need all not rebulid communication channel, thereby save the time at each communication.In addition, server end is when receiving client data, because the length of pre-primary data, therefore buffering area (Buffer) that can be suitable according to its length Dynamic Definition when each read data has been saved system resource.
Further describe specific embodiments of the invention below in conjunction with accompanying drawing.
Description of drawings
Fig. 1 is the Organization Chart of known technology server end;
Fig. 2 is the data structure diagram of known technology client;
Fig. 3 is the operation workflow figure of the dynamic implementation method of the network service carried of the present invention;
Fig. 4 is general frame figure of the present invention;
Fig. 5 A~Fig. 5 C is a data structure diagram of the present invention;
Fig. 6 is the Organization Chart that a plurality of clients of server-side processes of the present invention connect; And
Fig. 7 is the data format schematic diagram of the embodiment of the invention.
Wherein, description of reference numerals is as follows:
10 main programs
20 threads 1
30 thread N
40 exit command
50 withdraw from
60 command words
70 data lengths
80 True Datas
90 data queues
100 command word length
210 data values
Step 310 is created data channel according to the connection request of this client, sets up being connected of this server end and this client
This client specified data form of step 320, wherein this data format comprises command word, data length and True Data
This client of step 330 dynamically generates packet according to this data format, and sends it to server end
This server end of step 340 receives this packet, and according to this data length wherein, distributes the buffering area of respective length
Step 350 is stored to the True Data in this packet in this buffering area
410 client threads
420 server end threads
Step 411 is set up Socket and is connected
Step 412 is according to the formula padding data bag that promptly fixes
Step 413 sends packet
Step 421 is set up Socket and is connected
Step 422 receives packet
Step 423 processing command word 1 packet
Step 424 processing command word 2 packets
Step 425 processing command word 3 packets
Embodiment
The present invention is a kind of dynamic implementation method of network service, at first method of the present invention is described by Fig. 3, the inventive method comprises that client dynamically builds the bag and the process of server dynamic analysis, at first step 310 is created data channel according to the connection request of this client, sets up being connected of this server end and this client; Step 320 client specified data form, wherein this data format comprises command word, data length and True Data; Step 330 client dynamically generates packet according to this data format, and sends it to server end; After step 340 server end receives this packet, carry out dynamic analysis,, distribute the buffering area of respective length according to this data length wherein; Step 350 is stored to the True Data in this packet in this buffering area again.
See also Fig. 4, this figure is general frame figure of the present invention, comprises client thread 410 and server end thread 420.As communicating by the Internet, need a pair of socket at least, one of them runs on client-side, is referred to as ClientSocket, and another runs on server end, is referred to as ServerSocket.Socket is the foundation stone of communication, is the basic operation unit of supporting the network service of ICP/IP protocol, is the end points that the process between different server and client is carried out two-way communication.Set up after Socket connects by step 411, step 421, client enters dynamic package process, step 412 is according to predetermined data packet format padding data bag, and data format comprises command word 60, data length 70 and True Data 80 shown in Fig. 5 A.Wherein command word 60 all is the length of fixing with data length 70.Command word 60 can be defined by the user, as long as client and server end are consistent just can realize.Data length 70 is the length that is used for the record data stream real data, can define Buffer to receiving terminal like this and provide convenience.True Data 80 is exactly the real data of using of receiving terminal.Step 413 sends to server end with packet then, after step 422 server end receives this packet, carry out dynamic analysis, according to the data length that obtains in advance, definition is used to receive the Buffer of data, and the command word in the judgment data bag, enter corresponding handling process according to different orders then, execution in step 423 processing command words 1 packet, step 424 processing command word 2 packets in order successively, and step 425 processing command word 3 packets, thereby the form according to packet comes out the analysis of data integrity, offers the Sever end and uses.After receiving, the Server end still can continue to wait for the request of Client end, does not withdraw from this thread, can avoid frequently creating the resource occupation of data channel like this.
Above-mentioned data format is a reference format, certainly also can expand it, the form of expansion sees also Fig. 5 B, and this form comprises data queue 90, data queue is the combination of some data just, and the packet of this form has just become the combination of command word 60 with data queue 90.Wherein comprise the combination of several data item numbers, several data lengths and True Data in the data queue.
Data format also can be the form shown in Fig. 5 C, it also is the distortion of reference format, this form is mainly used under the different situation of command word length, increased command word length 100, the packet of this form also can be a data formation at the data item branch, and the definition of data length also can dynamically be specified.
Wherein when a plurality of clients were sent connection request, the Sever end then needed to set up a plurality of threads, and as shown in Figure 6, this figure is the Organization Chart of a plurality of threads of server-side processes of the present invention.Main program 10 connects a plurality of threads, if N client-requested arranged, then sets up N thread 20,30 (thread 1, thread N), 40 finishes and withdraws from 50 operation by exiting command.In order to satisfy multi-user's demand, the Server end distributes a thread that is used to preserve communication pipe for each Client end, when the Client end has request of data, and Server end and can obtain message and set up the Socket connection.With creating the ServerSocket object and waiting for that the code that client program is connected is placed in the active process, whenever send a connection later on, then create and activate a thread and handle.After disposing, the Server end is waited for the request of next Client, does not withdraw from this thread, when the Client end no longer includes any request, just the word that exits command that pre-defines can be issued the Sever end, after Sever terminates to, promptly can realize initiatively withdrawing from.
Said process is a process of dynamically building bag (Client end) and dynamic analysis (Server end), wherein Client and Server are not unalterable, it depends on the flow direction of data, and when data flow was opposite, the role of Client and Server also can correspondingly change.
See also Fig. 7, this figure is the data format schematic diagram of the embodiment of the invention.As shown in the figure, after server end and client connected, step 710 was asked corresponding configuration information from the Server of appointment, and the command word here is GET_CONFIG, and additional information parameter is character string HELLO (integer between the two is a parameter length).Step 720, the state that Server end will be finished after will operating after the processing returns to Client, the command word here is REPORT_STATUS, and additional parameter is character string OK, and the request of illustrating is passed through, if ERROR, then explanation makes mistakes (integer between the two is a parameter length), and step 730Client obtains a Tool to the Server request, and the command word here is GET_NEXT_TOOL, additional parameter is TOOL1, shows the title (integer between the two is a parameter length) of Tool.Step 740, Server passes to Client with Tool, the word REPORT_STATUS that gives an order then, parameter is START, illustrates that Tool can normally move, otherwise is error handling processing (integer between the two is a parameter length).Step 750, Client obtains beginning to carry out behind the Tool, carries out the back and holds the word GET_NEXT_TOOL that gives an order to Server, and parameter is LOGOUOT, illustrates that Tool is executed correctly and has normally withdrawed from, otherwise make mistakes (integer between the two is a parameter length).Step 760, Client end program withdraws from, and withdraws from after the Server end is carried out everything.
The above is preferred embodiment of the present invention only, is not to be used for limiting practical range of the present invention; Every according to equivalence variation and modification that the present invention did, all contained by claim of the present invention.

Claims (10)

1, a kind of dynamic implementation method of network service is used to realize the dynamic data exchange of server end and client, it is characterized in that, comprises the steps:
Create data channel according to the connection request of this client, set up being connected of this server end and this client;
This client specified data form, this data format comprises command word, data length and True Data;
This client dynamically generates packet according to this data format, and this packet is sent to server end;
This server end receives this packet, and according to this data length, distributes the buffering area of respective length; And
True Data in this packet is stored to this buffering area.
2, the dynamic implementation method of network service according to claim 1 is characterized in that, also comprises the quantity according to client, creates the step of the thread of respective numbers.
3, the dynamic implementation method of network service according to claim 1 is characterized in that, after the described step that True Data is stored to this buffering area, also comprises the step of the request that continues to wait for client.
4, the dynamic implementation method of network service according to claim 1 is characterized in that, also comprises the request of withdrawing from according to this client, disconnects the step of connecting of this client and this server end.
5, the dynamic implementation method of network service according to claim 4 is characterized in that, described to withdraw from request be that command word in the data format is for exiting command.
6, the dynamic implementation method of network service according to claim 1 is characterized in that, described data format is command word and data queue.
7, the dynamic implementation method of network service according to claim 6 is characterized in that, described data queue comprises data item number and data length and True Data.
8, the dynamic implementation method of network service according to claim 1 is characterized in that, described data format also comprises command word length.
9, the dynamic implementation method of network service according to claim 1 is characterized in that, described this server end of setting up is set up this server end with being connected to of this client and is connected with the socket of this client.
10, the dynamic implementation method of network service according to claim 1 is characterized in that, described command word is that the user defines jointly at this server end and this client.
CN 200410031052 2004-04-12 2004-04-12 Dynamic realizing method of network communication Pending CN1684413A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200410031052 CN1684413A (en) 2004-04-12 2004-04-12 Dynamic realizing method of network communication

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200410031052 CN1684413A (en) 2004-04-12 2004-04-12 Dynamic realizing method of network communication

Publications (1)

Publication Number Publication Date
CN1684413A true CN1684413A (en) 2005-10-19

Family

ID=35263555

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200410031052 Pending CN1684413A (en) 2004-04-12 2004-04-12 Dynamic realizing method of network communication

Country Status (1)

Country Link
CN (1) CN1684413A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103023602A (en) * 2011-09-20 2013-04-03 镇江雅迅软件有限责任公司 Data transmission fault tolerance system based on Socket protocol
WO2017206601A1 (en) * 2016-05-30 2017-12-07 深圳市鼎盛智能科技有限公司 Client data processing method and apparatus
CN107454177A (en) * 2017-08-15 2017-12-08 合肥丹朋科技有限公司 The dynamic realizing method of network service
CN110995832A (en) * 2019-11-29 2020-04-10 安徽江淮汽车集团股份有限公司 Vehicle data monitoring method and system

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103023602A (en) * 2011-09-20 2013-04-03 镇江雅迅软件有限责任公司 Data transmission fault tolerance system based on Socket protocol
WO2017206601A1 (en) * 2016-05-30 2017-12-07 深圳市鼎盛智能科技有限公司 Client data processing method and apparatus
CN107454177A (en) * 2017-08-15 2017-12-08 合肥丹朋科技有限公司 The dynamic realizing method of network service
CN110995832A (en) * 2019-11-29 2020-04-10 安徽江淮汽车集团股份有限公司 Vehicle data monitoring method and system

Similar Documents

Publication Publication Date Title
US6922727B2 (en) Method and system for managing parallel data transfer through multiple sockets to provide scalability to a computer network
CN108270732B (en) A kind of Streaming Media processing method and system
CN101447981B (en) Client-server interaction method based on LDAP protocol and system thereof
CN110134534B (en) System and method for optimizing message processing for big data distributed system based on NIO
CN1791037A (en) Method for realizing Web service automatic test
CN1921438A (en) Method for realizing acceleration between networks by using proxy
CN102469064A (en) Method for implementing communication and communication equipment
WO2012065520A1 (en) System and method for file transmission
WO2014180407A1 (en) Pushing method and device therefor
CN1870767A (en) Method for managing timer task
CN1852411A (en) Electronic performance-bill server depolying system and method for set-up and oper ation
CN109547162B (en) Data communication method based on two sets of one-way boundaries
CN1812405A (en) Reliable one-way messaging over request-response transport protocols
WO2023000940A1 (en) Data processing method and apparatus, and network element device, storage medium and program product
CN1933454A (en) Synchronous information interface realizing method based on JAVA information service
WO2012151920A1 (en) Method and device for service transmission
CN1976322A (en) Method and system for realizing multimedia immediate communicating and control flow
CN1879368A (en) Using ordered locking mechanisms to maintain sequences of items such as packets
CN1949203A (en) Architecture of interface target machine for miniature computer system and data transmitting method
CN1921460A (en) Method of controlling data transmission and network apparatus for transmitting data using the same
CN1684413A (en) Dynamic realizing method of network communication
CN100486329C (en) Method for interface adaptation between IPTV and stream media equipment
CN1855824A (en) Method and apparatus for streaming data
CN100341270C (en) Method for reflecting task progress of message based distributed platform client
CN1905476A (en) Managing system and method for terminal products

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication