CN109189718A - A kind of SOCKET Component that supporting multiple network interface and method - Google Patents

A kind of SOCKET Component that supporting multiple network interface and method Download PDF

Info

Publication number
CN109189718A
CN109189718A CN201811065086.0A CN201811065086A CN109189718A CN 109189718 A CN109189718 A CN 109189718A CN 201811065086 A CN201811065086 A CN 201811065086A CN 109189718 A CN109189718 A CN 109189718A
Authority
CN
China
Prior art keywords
socket
network interface
parameter
module
network
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.)
Granted
Application number
CN201811065086.0A
Other languages
Chinese (zh)
Other versions
CN109189718B (en
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.)
Shanghai Ruisaide Electronic Technology Co Ltd
Original Assignee
Shanghai Ruisaide Electronic Technology Co Ltd
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 Shanghai Ruisaide Electronic Technology Co Ltd filed Critical Shanghai Ruisaide Electronic Technology Co Ltd
Priority to CN201811065086.0A priority Critical patent/CN109189718B/en
Publication of CN109189718A publication Critical patent/CN109189718A/en
Application granted granted Critical
Publication of CN109189718B publication Critical patent/CN109189718B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/16Combinations of two or more digital computers each having at least an arithmetic unit, a program unit and a register, e.g. for a simultaneous processing of several programs
    • G06F15/163Interprocessor communication
    • G06F15/173Interprocessor communication using an interconnection network, e.g. matrix, shuffle, pyramid, star, snowflake
    • G06F15/17306Intercommunication techniques
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Abstract

The disclosure provides a kind of SOCKET Component for supporting multiple network interface and method, is related to the communications field and computer field.The SOCKET Component that the disclosure provides is applied to electronic equipment, and the SOCKET Component includes socket abstraction layer module and Network Interface Module;The Network Interface Module includes a plurality of types of network interfaces;The socket abstraction layer module receives the first parameter for having network interface for identification in advance, the socket abstraction layer module is used to identify corresponding target network interface from a plurality of types of network interfaces according to first parameter, and is matched with the target network interface.The SOCKET Component and method of the support multiple network interface that the disclosure provides support the identification and matching of a plurality of types of network interfaces by socket abstraction layer module, solves the dependence to single network interface, the versatility of application program is improved, transplanting difficulty is reduced.

Description

A kind of SOCKET Component that supporting multiple network interface and method
Technical field
This disclosure relates to the communications field and computer field, in particular to a kind of set for supporting multiple network interface Connect word component and method.
Background technique
As embedded system is in the high speed development of field of communication technology, same application is in the feelings for facing heterogeneous networks interface Under condition, the needs that will lead to application layer change with the variation of heterogeneous networks interface, can not support multiple network interface, replacement Different network interfaces, the application program of early period just need to reconfigure, and the efficiency that program is reused greatly are reduced, to exploitation Person brings the deuce to pay.
Summary of the invention
In view of this, the disclosure provides a kind of SOCKET Component for supporting multiple network interface and method.
A kind of SOCKET Component for supporting multiple network interface that the disclosure provides is applied to electronic equipment, the socket Word component includes socket abstraction layer module and Network Interface Module.
The Network Interface Module includes a plurality of types of network interfaces.
The socket abstraction layer module receives the first parameter for having network interface for identification in advance, and the socket is taken out As layer module is used to identify that corresponding target network connects from a plurality of types of network interfaces according to first parameter Mouthful, and matched with the target network interface.
Further, a plurality of types of network interfaces include the network interface of network module type, network chip class The network interface of type and the network interface of network protocol stack type.
Further, the SOCKET Component further includes general socket interface module and Virtual File System module, The Virtual File System module is for providing socket descriptor.
The general socket interface module is used for incoming in the socket and application layer for obtaining the application layer creation The first parameter after, by socket abstraction layer module described in function call, by socket that the application layer creates and answer It is passed to the first parameter that layer is passed to the socket abstraction layer module.
The socket abstraction layer module is used to receive the incoming socket of the general socket interface module After word and the first parameter, apply for the socket descriptor that the Virtual File System module provides, and to the socket word description Distribution structure body space is accorded with, by first parameter setting into the structural body space, so that the socket level of abstraction mould Root tuber identifies corresponding target network interface according to first parameter from a plurality of types of network interfaces, and with it is described Target network interface is matched.
Further, first parameter includes protocol family parameter, Socket type and specified protocol.
The socket abstraction layer module is used to identify a plurality of types of network interfaces according to the protocol family parameter.
The SOCKET Component is used to determine the transmission mode of the socket according to the Socket type.
The application layer is used to determine Data Transport Protocol during network communication according to the specified protocol.
Further, the socket abstraction layer module includes that computer network with standard network protocol stack, self-defined network protocol, network connect Mouth operating method and socket data structure.
The computer network with standard network protocol stack is for providing general network interface implementation, so that the socket level of abstraction Module is matched with general network interface realization.
The self-defined network protocol connects heterogeneous networks with meeting for providing customized network interface implementation Cause for gossip shows matched demand.
The network interface operations method includes the network interface of the network interface of network module type, network chip type And the operating method of the network interface of network protocol stack type, for matching heterogeneous networks interface.
The socket data structure is used to receive and the first parameter of a plurality of types of network interfaces of store identification.
The socket abstraction layer module according to first parameter from a plurality of types of network interfaces for knowing Not Chu corresponding target network interface, and matched by the network interface operations method with the target network interface.
The disclosure provides a kind of method for supporting multiple network interface, is applied to electronic equipment, and the electronic equipment includes Above-mentioned SOCKET Component, the SOCKET Component include socket abstraction layer module and Network Interface Module, the network Interface module includes a plurality of types of network interfaces, which comprises
The socket abstraction layer module receives the first parameter of network interface for identification.
The socket abstraction layer module is identified from a plurality of types of network interfaces according to first parameter Corresponding target network interface.
The socket abstraction layer module is matched with the target network interface.
Further, a plurality of types of network interfaces include the network interface of network module type, network chip class The network interface of type and the network interface of network protocol stack type.
Further, the SOCKET Component further includes general socket interface module and Virtual File System module, institute Stating the step of socket abstraction layer module receives the first parameter of network interface for identification includes:
The general socket interface module obtains the socket of application layer creation and the first parameter that application layer is incoming.
The general socket interface module calls the socket abstraction layer module, the socket that the application layer is created The first parameter that word and application layer are passed to is passed to the socket abstraction layer module.
The socket descriptor that Virtual File System module described in the socket abstraction layer module application provides.
The socket abstraction layer module is to the socket descriptor distribution structure body space.
By first parameter setting into the structural body space.
The socket abstraction layer module is identified from a plurality of types of network interfaces according to first parameter Corresponding target network interface.
Further, first parameter includes protocol family parameter, Socket type and specified protocol.
The socket abstraction layer module identifies a plurality of types of network interfaces according to the protocol family parameter.
The SOCKET Component determines the transmission mode of the socket according to the Socket type.
The application layer determines Data Transport Protocol during network communication according to the specified protocol.
Further, the socket abstraction layer module is known from a plurality of types of network interfaces according to first parameter Chu not include: the step of corresponding target network interface
The socket abstraction layer module finds use according to the second parameter of the target network interface from the first parameter In the parameter for matching the target network interface.
The parameter for being used to match the target network interface will be searched out and second parameter compares.
If the parameter searched out for matching the target network interface is consistent with second parameter, by institute Socket abstraction layer module is stated to be matched with the target network interface.
After matching, the socket abstraction layer module obtains the socket descriptor, by the socket word description Symbol is arranged into the structural body space of the socket abstraction layer module.
Return parameters are set, the structural body parameter in the structural body space of the socket abstraction layer module is back to application Layer.
The SOCKET Component and method for the support multiple network interface that the disclosure provides, it is preparatory in socket abstraction layer module The first parameter for having network interface for identification is received, correspondence is identified from a plurality of types of network interfaces according to the first parameter Target network interface, and matched with target network interface, the SOCKET Component and method support a plurality of types of networks The identification and matching of interface, replace different network interfaces, need to only identify again to the network interface of replacement, and again Match, reconfigured without the application program to early period, solve dependence of the application layer to single network interface, improves and apply journey The versatility of sequence.
To enable the above objects, features, and advantages of the disclosure to be clearer and more comprehensible, preferred embodiment is cited below particularly, and cooperate Appended attached drawing, is described in detail below.
Detailed description of the invention
In order to illustrate more clearly of the technical solution of the disclosure, letter will be made to attached drawing needed in the embodiment below It singly introduces, it should be understood that the following drawings illustrates only some embodiments of the disclosure, therefore is not construed as to range It limits, it for those of ordinary skill in the art, without creative efforts, can also be according to these attached drawings Obtain other relevant attached drawings.
Fig. 1 is a kind of block diagram of SOCKET Component provided by the disclosure.
Fig. 2 is a kind of another block diagram of SOCKET Component provided by the disclosure.
Fig. 3 is a kind of flow diagram for the method for supporting network interface provided by the disclosure.
Fig. 4 receives the first ginseng for socket abstraction layer module in a kind of method for supporting network interface provided by the disclosure Several flow diagrams.
Fig. 5 is socket abstraction layer module and target network in a kind of method for supporting network interface provided by the disclosure Interface identifies matched flow diagram.
Fig. 6 is socket abstraction layer module and target network in a kind of method for supporting network interface provided by the disclosure Flow diagram after Interface Matching.
Fig. 7 is a kind of flow diagram of reception/transmission data provided by the disclosure.
Icon: 100- SOCKET Component;10- sockets interface module;20- Virtual File System module;30- socket Word abstraction layer module;31- socket data structure;32- computer network with standard network protocol stack;33- self-defined network protocol;34- net Network interface operation method;40- Network Interface Module;The network interface of 41- network module type;42- network chip type Network interface;The network interface of 43- network protocol stack type.
Specific embodiment
Below in conjunction with attached drawing in the disclosure, the technical solution in the disclosure is clearly and completely described, it is clear that Described embodiment is only disclosure a part of the embodiment, instead of all the embodiments.Usually retouched in attached drawing here The component for the disclosure stated and shown can be arranged and be designed with a variety of different configurations.Therefore, below to mentioning in the accompanying drawings The detailed description of the embodiment of the disclosure of confession is not intended to limit claimed the scope of the present disclosure, but is merely representative of this Disclosed selected embodiment.Based on embodiment of the disclosure, those skilled in the art are in the premise for not making creative work Under every other embodiment obtained, belong to the disclosure protection range.
It should also be noted that similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi It is defined in a attached drawing, does not then need that it is further defined and explained in subsequent attached drawing.
As embedded system is in the high speed development of field of communication technology, existing same application connects in face of heterogeneous networks Mouthful, the needs that will lead to application layer change with the variation of heterogeneous networks interface, can not support multiple network interface, replacement is not Same network interface, the application program of early period just need to reconfigure, and greatly reduce the efficiency that program is reused, give developer Bring the deuce to pay.
Based on the studies above, the disclosure provides a kind of SOCKET Component for supporting multiple network interface and method.
Fig. 1 is please referred to, Fig. 1 is a kind of block diagram of SOCKET Component 100 provided by the disclosure.The disclosure A kind of SOCKET Component 100 provided, is applied to electronic equipment, and the SOCKET Component 100 includes socket abstraction layer module 30 and Network Interface Module 40.
Optionally, the concrete type of the electronic equipment is unrestricted, for example, it may be, but be not limited to, intelligent sound box, Smart home, the wisdom energy, intelligent electric meter etc. have the embedded device of data communication function.
Further, the Network Interface Module 40 includes a plurality of types of network interfaces.
The socket abstraction layer module 30 receives the first parameter for having network interface for identification, the socket in advance Abstraction layer module 30 is used to identify corresponding target network from a plurality of types of network interfaces according to first parameter Network interface, and matched with the target network interface.
Wherein, a plurality of types of network interfaces include the network interface 41 of network module type, network chip type Network interface 42 and network protocol stack type network interface 43, but a plurality of types of network interfaces include but unlimited Network interface mentioned by the disclosure.
Further, the SOCKET Component 100 further includes general socket interface module 10 and Virtual File System Module 20, the Virtual File System module 20 is for providing socket descriptor.
The general socket interface module 10 is used to pass in the socket and application layer that obtain the application layer creation After the first parameter entered, by socket abstraction layer module 30 described in function call, the socket that the application layer is created with And the first parameter that application layer is passed to is passed to the socket abstraction layer module 30.
Wherein, by socket abstraction layer module 30 described in function call, the socket that the application layer creates is passed to After to the socket abstraction layer module 30, the socket abstraction layer module 30 carries out the socket that the application layer creates Setting, including be arranged socket parameter and setting registered callbacks function, wherein by setting socket parameters, with for With the target network interface;By the way that registered callbacks function is arranged, after the completion of being matched with the target network interface, to pass through Registered callbacks function calls the target network interface.
The socket abstraction layer module 30 be used for receive the general socket interface module 10 it is incoming described in After socket and the first parameter, apply for the socket descriptor that the Virtual File System module 20 provides, and to the socket Word description accords with distribution structure body space, by first parameter setting into the structural body space, so that the socket is taken out As layer module 30 identifies corresponding target network interface from a plurality of types of network interfaces according to first parameter, And it is matched with the target network interface.
Wherein, the socket abstraction layer module 30 applies for the socket word description that the Virtual File System module 20 provides Symbol, and to the socket descriptor distribution structure body space, the socket abstraction layer module 30 is socket descriptor point The structural body space matched is sky, after first parameter setting to the structural body space, so that the socket level of abstraction Module 30 identifies corresponding target network interface according to first parameter from a plurality of types of network interfaces, and with The target network interface is matched.
Further, first parameter includes protocol family parameter, Socket type and specified protocol.
The socket abstraction layer module 30 is used to identify that a plurality of types of networks connect according to the protocol family parameter Mouthful.
The SOCKET Component 100 is used to determine the transmission mode of the socket according to the Socket type.
The application layer is used to determine Data Transport Protocol during network communication according to the specified protocol.
Wherein, after first parameter is passed to socket abstraction layer module 30, the socket level of abstraction mould Block 30 includes the protocol family parameter of multiple types network interface for identification.
The socket abstraction layer module 30 is according to the second parameter of the target network interface from the protocol family parameter Middle searching is for matching the parameter of the target network interface, if searching out the parameter for matching the target network interface, The protocol family parameter has just identified the type of the target network interface.
The socket abstraction layer module 30, which will search out, is used to match the parameter and described the of the target network interface Two parameters compare, if unanimously, the socket abstraction layer module 30 is matched with the target network interface.Institute The second parameter for stating target network interface is the special parameter of the target network interface, and different types of network interface is special It is also different to determine parameter.
Further, when the target network interface is replaced, the socket abstraction layer module 30 only needs root According to the third parameter of target network interface to be replaced, what is searched out in the protocol family parameter is used to match mesh to be replaced The parameter for marking network interface, the parameter for being used to match target network interface to be replaced and the third parameter are compared, If the parameter for matching target network interface to be replaced is consistent with the third parameter, the socket level of abstraction mould Block 30 is matched with target network interface to be replaced, it is possible to understand that ground, the third parameter are also the mesh to be replaced The special parameter of network interface is marked, in turn, application layer solves the dependence to single network interface in this way, and mentions The high versatility of program application.
Further, please refer to Fig. 2, the socket abstraction layer module 30 include computer network with standard network protocol stack 32, from Define network protocol 33, network interface operations method 34 and socket data structure 31.
The computer network with standard network protocol stack 32 is for providing general network interface implementation, so that the socket is abstract Layer module 30 is matched with general network interface realization.
The self-defined network protocol 33 is for providing customized network interface implementation, to meet to heterogeneous networks Interface realizes matched demand.
The network interface operations method 34 includes the network of the network interface 41 of network module type, network chip type The operating method of the network interface 43 of interface 42 and network protocol stack type, for matching heterogeneous networks interface.
The socket data structure 31 is used to receive and the first parameter of a plurality of types of network interfaces of store identification.
The socket abstraction layer module 30 is identified from a plurality of types of network interfaces according to first parameter Corresponding target network interface out, and matched by the network interface operations method 34 with the target network interface.
Wherein, the socket abstraction layer module 30 identifies the target according to the protocol family parameter in first parameter After network interface belongs to which type of network interface, and by the special parameter of the target network interface be used to match it is described After the parameter of target network interface completes comparison, when need to be matched, the socket abstraction layer module 30 then utilizes standard network Network protocol stack 32 or self-defined network protocol 33 by the network interface operations method 34 and the target network interface into Row matching.
After the completion of the socket abstraction layer module 30 is matched with the target network interface, operates the target network and connect Mouth carries out Initialize installation, to prepare to carry out data transmission in application layer and the target network interface.
After the completion of the socket abstraction layer module 30 is matched with the target network interface, the socket level of abstraction mould Block 30 obtains the socket descriptor, by the structure of socket descriptor setting to the socket abstraction layer module 30 In body space.
Return parameters are arranged in the socket abstraction layer module 30 simultaneously, by the structure of the socket abstraction layer module 30 The structural body parameter in body space is back to the application layer, realizes the data conversion between application layer and network hardware layer.
Fig. 3 is please referred to, is that the disclosure provides a kind of flow diagram of method for supporting multi-network interface, is applied to Electronic equipment, optionally, the concrete type of the electronic equipment are unrestricted, for example, it may be, but be not limited to, intelligent sound box, Smart home, the wisdom energy, intelligent electric meter etc. have the embedded device of data communication function.
The electronic equipment includes SOCKET Component 100 shown in FIG. 1, and the SOCKET Component 100 is taken out including socket As layer module 30 and Network Interface Module 40, the Network Interface Module 40 includes a plurality of types of network interfaces, below will Detailed process shown in Fig. 3 is described in detail.
Step S10: socket abstraction layer module 30 receives the first parameter of network interface for identification.
Step S20: the socket abstraction layer module 30 connects according to first parameter from a plurality of types of networks Corresponding target network interface is identified in mouthful.
Step S30: the socket abstraction layer module 30 is matched with the target network interface.
Wherein, a plurality of types of network interfaces include the network interface 41 of network module type, network chip type Network interface 42 and network protocol stack type network interface 43, but a plurality of types of network interfaces include but unlimited Network interface mentioned by the disclosure.
Fig. 4 is please referred to, the SOCKET Component 100 further includes general socket interface module 10 and virtual file system System module 20, is identified from a plurality of types of network interfaces in the socket abstraction layer module 30 according to first parameter Before corresponding target network interface, the socket abstraction layer module 30 receives the first parameter of network interface for identification Process the following steps are included:
Step S11: the general socket interface module 10 obtains the socket of application layer creation and application layer is passed to The first parameter.
Step S12: the general socket interface module 10 calls the socket abstraction layer module 30, by the application The first parameter that the socket and application layer of layer creation are incoming is passed to the socket abstraction layer module 30.
Wherein, by socket abstraction layer module 30 described in function call, the socket that the application layer creates is passed to After to the socket abstraction layer module 30, the socket abstraction layer module 30 carries out the socket that the application layer creates Setting, including be arranged socket parameter and setting registered callbacks function, wherein by setting socket parameters, with for With the target network interface;By the way that registered callbacks function is arranged, after the completion of being matched with the target network interface, to pass through Registered callbacks function calls the target network interface.
Step S13: the socket abstraction layer module 30 applies for the socket that the Virtual File System module 20 provides Descriptor.
Step S14: the socket abstraction layer module 30 is to the socket descriptor distribution structure body space.
Wherein, the socket abstraction layer module 30 is described at this time to the socket descriptor distribution structure body space Structural body space is sky, and the socket descriptor also has not been obtained in the socket abstraction layer module 30.
Step S15: by first parameter setting into the structural body space.
Wherein, by after first parameter setting to the structural body space, so that the socket abstraction layer module 30 Above-mentioned steps S20 is executed according to first parameter, and then so that the socket abstraction layer module 30 is joined according to described first Number identifies corresponding target network interface from a plurality of types of network interfaces.
Further, first parameter includes protocol family parameter, Socket type and specified protocol.
The socket abstraction layer module 30 identifies a plurality of types of network interfaces according to the protocol family parameter.
The SOCKET Component 100 determines the transmission mode of the socket according to the Socket type.
The application layer determines Data Transport Protocol during network communication according to the specified protocol.
Please refer to Fig. 5, the socket abstraction layer module 30 is according to first parameter from a plurality of types of networks Identify that the process of corresponding target network interface is further comprising the steps of in interface:
Step S21: the socket abstraction layer module 30 is joined according to the second parameter of the target network interface from first The parameter for matching the target network interface is found in number.
Wherein, after first parameter is passed to socket abstraction layer module 30, the socket level of abstraction mould Block 30 includes the protocol family parameter of multiple types network interface for identification, and the socket abstraction layer module 30 is according to the mesh Second parameter of mark network interface finds the parameter for matching the target network interface from the protocol family parameter.
Second parameter of the target network interface is the special parameter of the target network interface, different types of network Interface, special parameter are also different.
Step S22: the parameter for being used to match the target network interface will be searched out and second parameter compares.
Step S23: the parameter for matching the target network interface is searched out described in judgement is with second parameter It is no consistent, if the parameter searched out for matching the target network interface is consistent with second parameter, in execution Step S30 is stated, the socket abstraction layer module 30 is matched with the target network interface, if described search out use It is inconsistent in the parameter and second parameter for matching the target network interface, execute step S231.
Step S231: the result of creation failure is returned.
Wherein, if the parameter searched out for matching the target network interface and second parameter are different It causes, the socket abstraction layer module 30 returns to the result of creation failure to the application layer.
Further, Fig. 6 is please referred to, after matching, the socket abstraction layer module 30 operates the target Network interface carries out Initialize installation, to prepare to carry out data transmission in application layer and the target network interface, and it is described Socket abstraction layer module 30 executes step S31 to step S32.
Step S31: the socket abstraction layer module 30 obtains the socket descriptor, by the socket descriptor It is arranged into the structural body space of the socket abstraction layer module 30.
Step S32: setting return parameters, by the structural body parameter in the structural body space of the socket abstraction layer module 30 It is back to application layer.
Wherein, return parameters are arranged in the socket abstraction layer module 30, and the structural body parameter is back to described answer With layer, the data conversion between application layer and network hardware layer is realized.
Further, Fig. 7 is please referred to, Fig. 7 is a kind of transmission/reception data flow diagram that the disclosure provides, Transmission shown in Fig. 7/reception data flow is to have completed in the socket abstraction layer module 30 with the target network interface It is carried out after matching, realization application layer and the conversion of network hardware layer data.
Step S40: application layer starts transmission/reception data.
Step S41: calling sockets interface module 10, carries out data transmission/received preparation.
Wherein, the application layer passes through sockets interface module 10 described in function call, the sockets interface module 10 Carry out data transmission/received preparation.
Step S42: calling Virtual File System module 20, and the sockets interface module 10 obtains socket descriptor.
Wherein, the sockets interface module 10 passes through Virtual File System module 20 described in function call, the socket Word interface module 10 obtains the socket descriptor that the Virtual File System module 20 provides.
Step S43: judging whether socket descriptor obtains success, if obtaining failure, step S431 is carried out, if obtained Success is taken, S44 is thened follow the steps.
Step S431: transmission/reception failure result is returned.
Wherein, if the socket word description obtains failure, the sockets interface module 10 is returned to the application layer Transmission/reception failure result.
Step S44: socket abstraction layer module 30 is called to carry out data send/receive operation.
Wherein, the sockets interface module 10 passes through socket abstraction layer module 30 described in function call, the socket Word abstraction layer module 30 carries out data send/receive operation.
Step S45: judging whether data transmission/reception succeeds, if data transmission/reception failure, carries out step S451, If data transmission/reception success, thens follow the steps S452.
Step S451: transmission/reception failure result is returned.
Wherein, if data transmission/reception failure, the socket abstraction layer module 30 is returned to the application layer Data transmission/reception failure result.
Step 452: returned data transmission/reception is successfully as a result, transmission/reception terminates.
Wherein, if data transmission/reception success, the socket abstraction layer module 30 are returned to the application layer Data transmission/successful the result of reception.
To sum up, the SOCKET Component and method for the support multiple network interface that the disclosure provides, in socket level of abstraction mould Block is passed to the first parameter for having network interface for identification in advance, is identified from a plurality of types of network interfaces according to the first parameter Corresponding target network interface out, and matched with target network interface, the SOCKET Component and method are taken out by socket As layer supports the identification and matching of a plurality of types of network interfaces, different network interfaces is replaced, the network of replacement need to only be connect Mouth is identified again, and is matched again, reconfigures without the application program to early period, solves application layer to single net The dependence of network interface improves the versatility of programming, shortens the development cycle, avoids design iterations.
In the embodiment provided by the disclosure, it should be understood that disclosed component and method, it can also be by other Mode realize.Component and embodiment of the method described above is only schematical, for example, flow chart and frame in attached drawing Figure shows the component according to the embodiment of the present disclosure, the architectural framework in the cards of method and computer program product, function And operation.In this regard, each box in flowchart or block diagram can represent one of a module, section or code Point, a part of the module, section or code includes one or more for implementing the specified logical function executable Instruction.It should also be noted that function marked in the box can also be attached to be different from some implementations as replacement The sequence marked in figure occurs.For example, two continuous boxes can actually be basically executed in parallel, they sometimes may be used To execute in the opposite order, this depends on the function involved.It is also noted that each of block diagram and or flow chart The combination of box in box and block diagram and or flow chart can be based on the defined function of execution or the dedicated of movement The system of hardware is realized, or can be realized using a combination of dedicated hardware and computer instructions.
In addition, each functional module in each embodiment of the disclosure can integrate one independent portion of formation together Point, it is also possible to modules individualism, an independent part can also be integrated to form with two or more modules.
It, can be with if the function is realized and when sold or used as an independent product in the form of software function module It is stored in a computer readable storage medium.Based on this understanding, the technical solution of the disclosure is substantially in other words The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a People's computer, electronic equipment or network equipment etc.) execute all or part of step of each embodiment the method for the disclosure Suddenly.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or equipment for including a series of elements not only includes those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or equipment institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including institute State in the process, method, article or equipment of element that there is also other identical elements.In addition, term " first ", " second " etc. It is only used for distinguishing description, is not understood to indicate or imply relative importance.
The foregoing is merely the alternative embodiments of the disclosure, are not limited to the disclosure, for the skill of this field For art personnel, the disclosure can have various modifications and variations.It is all within the spirit and principle of the disclosure, it is made any to repair Change, equivalent replacement, improvement etc., should be included within the protection scope of the disclosure.

Claims (10)

1. a kind of SOCKET Component for supporting multiple network interface, which is characterized in that be applied to electronic equipment, the socket group Part includes socket abstraction layer module and Network Interface Module;
The Network Interface Module includes a plurality of types of network interfaces;
The socket abstraction layer module receives the first parameter for having network interface for identification, the socket level of abstraction in advance Module is used to according to first parameter identify corresponding target network interface from a plurality of types of network interfaces, and It is matched with the target network interface.
2. SOCKET Component according to claim 1, which is characterized in that a plurality of types of network interfaces include network The network interface of the network interface of module type, the network interface of network chip type and network protocol stack type.
3. SOCKET Component according to claim 1, which is characterized in that the SOCKET Component further includes general socket Interface module and Virtual File System module, the Virtual File System module is for providing socket descriptor;
The general socket interface module is used for first ginseng incoming in the socket and application layer for obtaining application layer creation After number, by socket abstraction layer module described in function call, socket and application layer that the application layer creates are passed to The first parameter be passed to the socket abstraction layer module;
The socket abstraction layer module be used for receive the incoming socket of the general socket interface module and After first parameter, apply for the socket descriptor that the Virtual File System module provides, and to the socket descriptor point Distribution structure body space, by first parameter setting into the structural body space, so that the socket abstraction layer module root Identify corresponding target network interface from a plurality of types of network interfaces according to first parameter, and with the target Network interface is matched.
4. SOCKET Component according to claim 3, which is characterized in that first parameter includes protocol family parameter, set Connect word type and specified protocol;
The socket abstraction layer module is used to identify a plurality of types of network interfaces according to the protocol family parameter;
The SOCKET Component is used to determine the transmission mode of the socket according to the Socket type;
The application layer is used to determine Data Transport Protocol during network communication according to the specified protocol.
5. SOCKET Component according to claim 1, which is characterized in that the socket abstraction layer module includes standard network Network protocol stack, self-defined network protocol, network interface operations method and socket data structure;
The computer network with standard network protocol stack is for providing general network interface implementation, so that the socket abstraction layer module It is matched with general network interface realization;
The self-defined network protocol is real to heterogeneous networks interface to meet for providing customized network interface implementation Existing matched demand;
The network interface operations method includes the network interface and net of the network interface of network module type, network chip type The operating method of the network interface of network agreement stack type, for matching heterogeneous networks interface;
The socket data structure is used to receive and the first parameter of a plurality of types of network interfaces of store identification;
The socket abstraction layer module according to first parameter from a plurality of types of network interfaces for identifying Corresponding target network interface, and matched by the network interface operations method with the target network interface.
6. a kind of method for supporting multiple network interface, which is characterized in that be applied to electronic equipment, the electronic equipment includes power Benefit requires the described in any item SOCKET Components of 1-5, and the SOCKET Component includes that socket abstraction layer module and network connect Mouth mold block, the Network Interface Module include a plurality of types of network interfaces, which comprises
The socket abstraction layer module receives the first parameter of network interface for identification;
The socket abstraction layer module identifies correspondence from a plurality of types of network interfaces according to first parameter Target network interface;
The socket abstraction layer module is matched with the target network interface.
7. according to the method described in claim 6, it is characterized in that, a plurality of types of network interfaces include network module class The network interface of the network interface of type, the network interface of network chip type and network protocol stack type.
8. according to the method described in claim 6, it is characterized in that, the SOCKET Component further includes general sockets interface mould The step of block and Virtual File System module, the socket abstraction layer module receives the first parameter of network interface for identification Include:
The general socket interface module obtains the socket of application layer creation and the first parameter that application layer is incoming;
The general socket interface module calls the socket abstraction layer module, the socket that the application layer is created with And the first parameter that the application layer is passed to is passed to the socket abstraction layer module;
The socket descriptor that Virtual File System module described in the socket abstraction layer module application provides;
The socket abstraction layer module is to the socket descriptor distribution structure body space;
By first parameter setting into the structural body space;
The socket abstraction layer module identifies correspondence from a plurality of types of network interfaces according to first parameter Target network interface.
9. according to the method described in claim 8, it is characterized in that, first parameter includes protocol family parameter, socket class Type and specified protocol;
The socket abstraction layer module identifies a plurality of types of network interfaces according to the protocol family parameter;
The SOCKET Component determines the transmission mode of the socket according to the Socket type;
The application layer determines Data Transport Protocol during network communication according to the specified protocol.
10. according to the method described in claim 8, it is characterized in that, the socket abstraction layer module is according to first ginseng Counting the step of identifying corresponding target network interface from a plurality of types of network interfaces includes:
The socket abstraction layer module found from the first parameter according to the second parameter of the target network interface for Parameter with the target network interface;
The parameter for being used to match the target network interface will be searched out and second parameter compares;
If the parameter searched out for matching the target network interface is consistent with second parameter, by the set Word abstraction layer module is connect to be matched with the target network interface;
After matching, the socket abstraction layer module obtains the socket descriptor, and the socket descriptor is set In the structural body space for setting the socket abstraction layer module;
Return parameters are set, the structural body parameter in the structural body space of the socket abstraction layer module is back to the application Layer.
CN201811065086.0A 2018-09-04 2018-09-04 Socket assembly and method for supporting multiple network interfaces Active CN109189718B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811065086.0A CN109189718B (en) 2018-09-04 2018-09-04 Socket assembly and method for supporting multiple network interfaces

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811065086.0A CN109189718B (en) 2018-09-04 2018-09-04 Socket assembly and method for supporting multiple network interfaces

Publications (2)

Publication Number Publication Date
CN109189718A true CN109189718A (en) 2019-01-11
CN109189718B CN109189718B (en) 2020-07-10

Family

ID=64910821

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811065086.0A Active CN109189718B (en) 2018-09-04 2018-09-04 Socket assembly and method for supporting multiple network interfaces

Country Status (1)

Country Link
CN (1) CN109189718B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110661692A (en) * 2019-11-13 2020-01-07 联想(北京)有限公司 Network interconnection system and method
CN113395293A (en) * 2021-07-13 2021-09-14 上海睿赛德电子科技有限公司 RPC-based network socket implementation method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102223307A (en) * 2011-06-29 2011-10-19 中兴通讯股份有限公司 Method for processing socket, method for grouped data transmission and device
CN102339234A (en) * 2011-07-12 2012-02-01 迈普通信技术股份有限公司 Device for operating protocol stack and method
CN104580124A (en) * 2013-10-29 2015-04-29 华为技术有限公司 Protocol stack selection method, device and equipment
CN106534178A (en) * 2016-12-08 2017-03-22 中国电子科技集团公司第三十二研究所 System and method for realizing RapidIO network universal socket

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102223307A (en) * 2011-06-29 2011-10-19 中兴通讯股份有限公司 Method for processing socket, method for grouped data transmission and device
CN102339234A (en) * 2011-07-12 2012-02-01 迈普通信技术股份有限公司 Device for operating protocol stack and method
CN104580124A (en) * 2013-10-29 2015-04-29 华为技术有限公司 Protocol stack selection method, device and equipment
CN106534178A (en) * 2016-12-08 2017-03-22 中国电子科技集团公司第三十二研究所 System and method for realizing RapidIO network universal socket

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
施瑞森: ""可编程控制器网络通信功能块技术研究与实现"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
郑昕: ""基于多核的网络应用接口的设计与实现"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110661692A (en) * 2019-11-13 2020-01-07 联想(北京)有限公司 Network interconnection system and method
CN113395293A (en) * 2021-07-13 2021-09-14 上海睿赛德电子科技有限公司 RPC-based network socket implementation method
CN113395293B (en) * 2021-07-13 2023-09-15 上海睿赛德电子科技有限公司 Network socket realizing method based on RPC

Also Published As

Publication number Publication date
CN109189718B (en) 2020-07-10

Similar Documents

Publication Publication Date Title
CN110348201A (en) A kind of configuration method and device of device security policy
CN104993947A (en) Method for upgrading firmware in batches
CN105224396A (en) A kind of business data processing method and device
CN109189718A (en) A kind of SOCKET Component that supporting multiple network interface and method
CN102902547A (en) Command construction and analysis method of command line interface
CN102073928A (en) Interface definition-based synchronous management method of resource accounts
WO2011085698A1 (en) Method for controlling resources on shared network element, shared network element and relevant device
CN112669110A (en) Server label management method and related equipment
CN107479940A (en) A kind of method and device for realizing Internet of Things module
CN110138579A (en) The configuration method and relevant apparatus of user side equipment
EP3157222A1 (en) Communication method and system based on assembled communication protocol stack
CN109165332A (en) A kind of webpage information acquisition methods, device and equipment
CN110442410A (en) Embedded type interface design method, device, electronic equipment and storage medium
CN104536759B (en) The general-purpose platform implementation method of business disc system management
CN109445384A (en) A kind of more apparatus control systems
CN103984540A (en) Method and device for generating hardware interface running program
CN107529180B (en) Base station cloud test environment construction device and method
CN112333672A (en) Method and device for opening UPF network element of 5G core network
CN111917592A (en) Centralized operation method and device for heterogeneous brand network equipment
CN109660379B (en) Network method, system and terminal
CN103077078A (en) Method of defining state transitions in a software and application control management object
CN105188077A (en) Communication module test method and system
CN105246132A (en) Parameter matching method and device for network access point
CN109525433A (en) A kind of router bgp status information batch monitoring method
CN109587255A (en) Service building method, system and the storage medium of dependence graph

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant