CN104519062A - Method and system for creating connection of multiple pairs of socket ports - Google Patents

Method and system for creating connection of multiple pairs of socket ports Download PDF

Info

Publication number
CN104519062A
CN104519062A CN201410788298.7A CN201410788298A CN104519062A CN 104519062 A CN104519062 A CN 104519062A CN 201410788298 A CN201410788298 A CN 201410788298A CN 104519062 A CN104519062 A CN 104519062A
Authority
CN
China
Prior art keywords
file
creating
socket
port
port numbers
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
CN201410788298.7A
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.)
Shenzhen Hangsheng Electronic Co Ltd
Original Assignee
Shenzhen Hangsheng Electronic 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 Shenzhen Hangsheng Electronic Co Ltd filed Critical Shenzhen Hangsheng Electronic Co Ltd
Priority to CN201410788298.7A priority Critical patent/CN104519062A/en
Publication of CN104519062A publication Critical patent/CN104519062A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a method and a system for creating connection of multiple pairs of socket ports and belongs to the field of process communication. The method includes the following steps: S1, starting to judge whether a file stored with port number data is available or not, if yes, executing S2, otherwise, creating a file, and storing the port number data prior to executing the S2; S2, reading the port number data in the file; S3, creating the same number of threads according to the number of pairs of port numbers; S4, creating socket connections as many as the threads, and ending. The method and the system are convenient to practical, only one file needs to be created, operation in process communication is simplified greatly, response time of a server is saved, and working efficiency is improved.

Description

A kind of method and system creating multipair socket port and connect
Technical field
The present invention relates to process communication field, particularly relate to a kind of method and system creating multipair socket port and connect.
Background technology
Socket is curstomer-oriented/server model and designs, and provides different Socket system calls for client and server program.Client applies for that a Socket(is equivalent to one and thinks that caller can dial-up on any integrated phone at random), system distributes one No. Socket for it; Server has the Socket that the overall situation is generally acknowledged, any client can send connection request and information request (be equivalent to a called phone and have the telephone number that a calling party knows) to it.Socket utilizes Client/Server to solve the problem established a communications link between process dexterously.
In prior art, when server end and client i.e. interapplication communications, each application program and corresponding a pair socket port of server end, each application program can only create a pair socket port, if want to create multipair socket port, can only open multiple application program one by one to create, this procedure be too loaded down with trivial details, operation is too many, brings a lot of inconvenience.
Summary of the invention
For solving problems of the prior art, the invention provides a kind of method creating multipair socket port and connect.
The present invention includes following steps:
S1: start, judge whether the file of storage port number exists, if perform S2, if not, then creates file, storage port number, and then performs S2;
S2: the port numbers data in file reading;
S3: the thread creating equal number according to the logarithm of port numbers;
S4: create the socket identical with number of threads and connect, terminate.
The present invention is further improved, and in step s 2, after the port numbers data in file reading, also comprises step: judge whether to read successfully, if so, performs step S3; If not, then revise file, then continue to perform step S2.
The present invention is further improved, and in step s3, after creating the thread of equal number, also comprises step: judge whether thread creates successfully, if so, perform step S4 according to the logarithm of port numbers; If not, then continue to perform step S3.
The present invention is further improved, and file exists, if changed in operation front port number, then need manual modification file, the method for amendment file is: open file, amendment file, storage port number, close file.
The present invention is further improved, and the quantity that the logarithm of described port numbers, described thread are connected with described socket is identical.
Present invention also offers a kind of system creating multipair socket port and connect, comprising judge module, for judging whether file exists; Read module, for the port numbers data in file reading; Create scheduler module, for creating the thread of equal number according to the logarithm of port numbers; Creating socket link block, connecting for creating the socket identical with number of threads.
The present invention is further improved, and in read module, after the port numbers data in file reading, also comprises: judge whether to read successfully, if so, performs and creates scheduler module; If not, then revise file, then continue to perform read module.
The present invention is further improved, in establishment scheduler module, after creating the thread of equal number according to the logarithm of port numbers, also comprise: judge whether thread creates successfully, if so, perform and create socket link block, if not, then continue to perform to create scheduler module.
Compared with prior art, the invention has the beneficial effects as follows: convenient and practical, only need to realize establishment file, automatically read multipair port numbers from file, once execute all operations, in process communication, enormously simplify operation, save the response time of server, improve operating efficiency.
Accompanying drawing explanation
Fig. 1 is the method flow diagram that the present invention creates the connection of multipair socket port;
Fig. 2 is the document method flow chart that the present invention creates storage port number.
Embodiment
Below in conjunction with drawings and Examples, the present invention is described in further details.
As shown in Figure 1, method of the present invention comprises the following steps:
S1: open application program, judges whether the file of storage port number exists, if perform S2, if file does not exist, then creates storage file, and the port numbers of write acquiescence refers to, preserves port numbers data, and then performs S2;
S2: the port numbers data in file reading;
S3: the thread creating equal number according to the logarithm of port numbers;
S4: create the socket identical with number of threads and connect, terminate.
Such as, if the logarithm of port numbers is N couple, then in step S2, reads N port number, then create N number of thread in step s3, equally, each thread is set up a pair socket port and is connected, and therefore, the present invention just creates N simultaneously and connects socket.
In order to ensure the successful that file reads, after the port numbers data in file reading, with the addition of determining step: judge whether to read successfully, if so, performing step S3; If not, then revise file, then continue to perform step S2;
Equally, whether creating successfully to understand thread in time, in step s3, after creating the thread of equal number according to the logarithm of port numbers, being also provided with determining step: judge whether thread creates successfully, if so, performing step S4; If not, then continue to perform step S3.
In addition, port numbers data must ensure the value between effective scope, otherwise socket connects would not be successful.
The file of storage port number creates in advance, if before program is run, port numbers data change, then need manual modification file, as shown in Figure 2, step is the method for amendment file: open file, amendment file, storage port number, close file.
Increase this two steps, the logarithm of described port numbers can be ensured, quantity that described thread is connected with described socket is identical.
Present invention also offers a kind of system realizing said method, comprise judge module, for judging whether file exists; Read module, for the port numbers data in file reading; Create scheduler module, for creating the thread of equal number according to the logarithm of port numbers; Creating socket link block, connecting for creating the socket identical with number of threads.
Equally, in order to ensure the reliability of program creation, in read module, after the port numbers data in file reading, also comprising: judge whether to read successfully, if so, performing and creating scheduler module; If not, then revise file, then continue to perform read module.In establishment scheduler module, after creating the thread of equal number according to the logarithm of port numbers, also comprise: judge whether thread creates successfully, if so, perform and create socket link block, if not, then continue to perform to create scheduler module.
Socket is also known as " socket ", and application program sends request or response network request by " socket " to network usually.
According to the target that the mode and local socket that connect startup will connect, the connection procedure between socket can be divided into three steps: server is monitored, client-requested, connects and confirms.
(1) server is monitored: be server side socket and the concrete client socket of delocalization, but the state to be connected such as to be in, real-time monitoring state of network.
(2) client-requested: refer to and propose connection request by the socket of client, the target that connect is the socket of server end.For this reason, first the socket of client must describe the socket of the server that it will connect, and points out address and the port numbers of server side socket, then just proposes connection request to server side socket.
(3) confirmation is connected: refer to when server side socket listens to the connection request receiving client socket in other words, it is with regard to the request of customer in response end socket, set up a new thread, client is issued in the description of server side socket, describe once client confirms this, connect and just established.And server side socket keeps listening state, continue the connection request receiving other client socket.
The present invention can open an application program and connect to create multipair socket port, and automatically read multipair port numbers from file, once execute all operations, such process is simple, easy to operate, saves time, raises the efficiency.
The embodiment of the above is better embodiment of the present invention; not limit specific embodiment of the invention scope with this; scope of the present invention comprises and is not limited to this embodiment, and all equivalence changes done according to the present invention are all in protection scope of the present invention.

Claims (8)

1. create the method that multipair socket port connects, it is characterized in that comprising the following steps:
S1: start, judge whether the file of storage port number exists, if perform S2, if not, then creates file, storage port number, and then performs S2;
S2: the port numbers data in file reading;
S3: the thread creating equal number according to the logarithm of port numbers;
S4: create the socket identical with number of threads and connect, terminate.
2. a kind of method creating multipair socket port and connect according to claim 1, is characterized in that: in step s 2, after the port numbers data in file reading, also comprises step: judge whether to read successfully, if so, perform step S3; If not, then revise file, then continue to perform step S2.
3. a kind of method creating multipair socket port and connect according to claim 1, it is characterized in that: in step s3, after creating the thread of equal number according to the logarithm of port numbers, also comprise step: judge whether thread creates successfully, if so, step S4 is performed; If not, then continue to perform step S3.
4. a kind of method creating multipair socket port and connect according to claim 1-3, it is characterized in that: file exists, if changed in operation front port number, then need manual modification file, the method of amendment file is: open file, amendment file, storage port number, close file.
5. a kind of method creating multipair socket port and connect according to claim 1-3, is characterized in that: the quantity that the logarithm of described port numbers, described thread are connected with described socket is identical.
6. realize the system of any one method described in claim 1-5, it is characterized in that: comprise judge module, for judging whether file exists;
Read module, for the port numbers data in file reading;
Create scheduler module, for creating the thread of equal number according to the logarithm of port numbers;
Creating socket link block, connecting for creating the socket identical with number of threads.
7. a kind of system creating multipair socket port and connect according to claim 6, is characterized in that: in read module, after the port numbers data in file reading, also comprises: judge whether to read successfully, if so, perform and create scheduler module; If not, then revise file, then continue to perform read module.
8. a kind of system creating multipair socket port and connect according to claim 6, it is characterized in that: in establishment scheduler module, after creating the thread of equal number according to the logarithm of port numbers, also comprise: judge whether thread creates successfully, if, perform and create socket link block, if not, then continue to perform to create scheduler module.
CN201410788298.7A 2014-12-17 2014-12-17 Method and system for creating connection of multiple pairs of socket ports Pending CN104519062A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410788298.7A CN104519062A (en) 2014-12-17 2014-12-17 Method and system for creating connection of multiple pairs of socket ports

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410788298.7A CN104519062A (en) 2014-12-17 2014-12-17 Method and system for creating connection of multiple pairs of socket ports

Publications (1)

Publication Number Publication Date
CN104519062A true CN104519062A (en) 2015-04-15

Family

ID=52793784

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410788298.7A Pending CN104519062A (en) 2014-12-17 2014-12-17 Method and system for creating connection of multiple pairs of socket ports

Country Status (1)

Country Link
CN (1) CN104519062A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105426242A (en) * 2015-11-17 2016-03-23 腾讯科技(深圳)有限公司 Data transmission method and device
CN105681930A (en) * 2016-01-12 2016-06-15 深圳羚羊极速科技有限公司 Way for establishing rapid tcp connection with streaming media server
CN110581843A (en) * 2019-08-21 2019-12-17 浙江大学 Mimic Web gateway multi-application flow directional distribution method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1267869A (en) * 2000-04-26 2000-09-27 深圳黎明电脑网络有限公司 Information exchanging matrix realizing method and module
WO2004088923A1 (en) * 2003-04-01 2004-10-14 Telefonaktiebolaget Lm Ericsson (Publ) Method and system for centrally allocating addresses and port numbers
CN103139157A (en) * 2011-11-28 2013-06-05 北京南车时代信息技术有限公司 Network communication method based on socket, device and system
CN104092794A (en) * 2014-07-25 2014-10-08 中国工商银行股份有限公司 Batch course processing method and system
CN104184729A (en) * 2014-08-20 2014-12-03 杭州华三通信技术有限公司 Message processing method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1267869A (en) * 2000-04-26 2000-09-27 深圳黎明电脑网络有限公司 Information exchanging matrix realizing method and module
WO2004088923A1 (en) * 2003-04-01 2004-10-14 Telefonaktiebolaget Lm Ericsson (Publ) Method and system for centrally allocating addresses and port numbers
CN103139157A (en) * 2011-11-28 2013-06-05 北京南车时代信息技术有限公司 Network communication method based on socket, device and system
CN104092794A (en) * 2014-07-25 2014-10-08 中国工商银行股份有限公司 Batch course processing method and system
CN104184729A (en) * 2014-08-20 2014-12-03 杭州华三通信技术有限公司 Message processing method and device

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105426242A (en) * 2015-11-17 2016-03-23 腾讯科技(深圳)有限公司 Data transmission method and device
CN105426242B (en) * 2015-11-17 2020-04-21 腾讯科技(深圳)有限公司 Data transmission method and device
CN105681930A (en) * 2016-01-12 2016-06-15 深圳羚羊极速科技有限公司 Way for establishing rapid tcp connection with streaming media server
CN110581843A (en) * 2019-08-21 2019-12-17 浙江大学 Mimic Web gateway multi-application flow directional distribution method
CN110581843B (en) * 2019-08-21 2020-12-15 浙江大学 Mimic Web gateway multi-application flow directional distribution method

Similar Documents

Publication Publication Date Title
WO2014106410A1 (en) Method for terminal acceleration, terminal and storage medium
CN109933439A (en) Method for message transmission, device, computer equipment and storage medium
CN103795569A (en) Server connection method and device based on connection pool
CN104519062A (en) Method and system for creating connection of multiple pairs of socket ports
CN109614232B (en) Task processing method and device, storage medium and electronic device
CN109800029A (en) Batch sets method, apparatus, terminal and the storage medium of server B IOS parameter
CN109451020A (en) Overtime management method, equipment and computer readable storage medium
CN108809683A (en) Dispose the method and device of cloud application system
CN106201638A (en) A kind of plug-in loading method, system, client and service end
CN111405059B (en) Cloud device data transmission method, electronic device and Internet of things system
CN113326083A (en) State machine processing method, state processing device, electronic equipment and storage medium
CN104519482A (en) Equipment parameter configuration method and device
EP3197207A1 (en) Method for managing application resources and registered node in m2m
CN106200866B (en) A kind of application freezing method and mobile terminal
CN113791792A (en) Application calling information acquisition method and device and storage medium
CN106412062A (en) Method and system for remotely loading engineering to device and monitoring operation state of engineering
CN110990116B (en) Method, device and system for transmitting data between intelligent network card and virtual machine
CN104462905A (en) Data processing method and device of operating systems and terminal
CN103297584B (en) A kind of acquisition method, system and mobile terminal remaining the air time
CN113326192B (en) Application testing method, device, equipment and storage medium for mobile terminal
CN105227345A (en) A kind of time-out time method to set up of connection and device
CN103152428A (en) Method for carrying out service communication among nodes on cloud platform
CN110971696B (en) System and method for realizing virtual electronic card communication
CN111930391B (en) Application data processing method and device, server and user terminal
CN113419880A (en) Cloud mobile phone root authority acquisition method, related device and computer program product

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20150415

RJ01 Rejection of invention patent application after publication