WO2014067327A1 - 一种Socket处理方法、装置和Web服务器 - Google Patents

一种Socket处理方法、装置和Web服务器 Download PDF

Info

Publication number
WO2014067327A1
WO2014067327A1 PCT/CN2013/082305 CN2013082305W WO2014067327A1 WO 2014067327 A1 WO2014067327 A1 WO 2014067327A1 CN 2013082305 W CN2013082305 W CN 2013082305W WO 2014067327 A1 WO2014067327 A1 WO 2014067327A1
Authority
WO
WIPO (PCT)
Prior art keywords
socket
event
web
web server
semaphore
Prior art date
Application number
PCT/CN2013/082305
Other languages
English (en)
French (fr)
Inventor
马雯娟
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Priority to US14/438,681 priority Critical patent/US9871885B2/en
Priority to EP13851976.4A priority patent/EP2899944B1/en
Publication of WO2014067327A1 publication Critical patent/WO2014067327A1/zh

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/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • H04L67/62Establishing a time schedule for servicing the requests
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/535Tracking the activity of the user

Definitions

  • the present invention relates to the field of communications, and in particular, to a Socket processing method, apparatus, and web server. Background technique
  • the browser-based user interface has been more and more widely used to replace the PC-side UI software in uFi-type devices and data card-type devices.
  • the browsers provided by clients such as computers and mobile phones can be conveniently and quickly accessed by accessing the webUI. Query and modify the basic configuration of the uFi or data card.
  • the webUI application must be based on a web server.
  • the main function of the web server is to provide an online information browsing service.
  • the communication technology used when establishing a web server connection with a client computer such as a computer or a mobile phone is called a Socket.
  • Socket communication mechanism of the embedded Rex system is different from the Socket mechanism of the embedded Linux system. It is a unique asynchronous, non-blocking Socket on the platform. Therefore, unlike the synchronous and blocking Socket, it does not have its own.
  • the timeout mechanism because under normal circumstances it does not require a timeout mechanism at all.
  • the reason for the problem is that the Web task does not wait for the semaphore sent by the underlying Socket and has been waiting. It cannot continue to process the connection, read, write, close, etc., and the Web server cannot continue to be accessed by the client. Further analysis found that the Web task does not wait for the semaphore sent by the underlying Socket because the Socket underlying layer does not listen to any Socket events on the client. By analyzing the TCP packet analysis of the 80 listening port, it is found that it does not send any Socket request to the listening port for some reason of the MAC client. Summary of the invention An object of the embodiments of the present invention is to provide a Socket processing method, apparatus, and web server, which can still be accessed when an abnormality occurs on the client.
  • an embodiment of the present invention provides a Socket processing method, which is used for a web server, and the web server is based on a platform that provides an asynchronous, non-blocking Socket, and the Socket processing method includes:
  • Socket event By registering a Socket event by an asynchronous selection operation according to the monitored client request; determining whether the Socket event is a READ event and/or a WRITE event, and obtaining a judgment result;
  • the timing is turned on;
  • the web task When the timing reaches a preset threshold, the web task does not receive the first semaphore sent by the bottom layer of the Socket, and sends a second semaphore to the web task, so that the web task can be activated, and according to the The Socket event is processed in the corresponding process.
  • the Socket processing method where the Socket processing method further includes:
  • the web task When the waiting time reaches a preset threshold, when the web task does not receive the first semaphore sent by the Socket, sends a second semaphore to the web task, so that the web task can be activated, and After the corresponding process is processed according to the Socket event, the Socket event is closed.
  • the above Socket processing method wherein the platform providing the asynchronous, non-blocking mode Socket is an embedded Rex system.
  • an embodiment of the present invention further provides a Socket processing apparatus, which is used in a Web server, and the Web server is based on an embedded Rex system, and the Socket processing apparatus includes:
  • a listening module configured to: listen for a client request of the web server port;
  • the registration module is configured to: register the Socket event by an asynchronous selection operation according to the monitored client request;
  • the judging module is configured to: determine whether the Socket event is a READ event and/or a WRITE Event, get a judgment result;
  • the timing module is configured to: when the judgment result indicates that the Socket event is a READ event and/or a WRITE event, turn on timing;
  • the semaphore sending module is configured to: when the timing reaches a preset threshold, the web task does not receive the first semaphore sent by the bottom layer of the Socket, and sends a second semaphore to the web task, so that the web The task can be activated and processed according to the Socket event.
  • the Socket closes the module, and is configured to: when the waiting time reaches a preset threshold, the web task does not receive the first semaphore sent by the bottom layer of the Socket, and sends a second semaphore to the web task, so that the The web task can be activated, and the Socket event is closed after the corresponding process is processed according to the Socket event.
  • the platform for providing an asynchronous, non-blocking Socket is an embedded Rex system.
  • the web server port is port 80.
  • an embodiment of the present invention further provides a web server, where the web server is based on a platform for providing an asynchronous, non-blocking Socket, including the Socket processing apparatus according to any one of the above items.
  • the web task when an abnormality occurs on the client, the web task is suspended because the semaphore is not received, the timing is started, the timing reaches a preset threshold, and the web task does not receive the first signal sent by the Socket. Sending a second semaphore to activate the web task, causing the web task to process the corresponding process according to the Socket event, and closing the abnormal Socket event, so that the client can re-initiate the connection with the web server to achieve continuous Access to the operation of the web server, ie the web server can still be accessed.
  • FIG. 1 is a flowchart of a Socket implementation in the related art
  • FIG. 2 is a schematic flowchart of a Socket processing method according to an embodiment of the present invention
  • 3 is a flowchart of implementing a Socket according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of a Socket processing apparatus according to an embodiment of the present invention.
  • the asynchronous selection operation registers the Socket event of interest; the Web task is in the state of waiting for the semaphore, that is, the task is equivalent to the task when waiting for the semaphore
  • the Web task is activated and the Web task processes the accept, read, write, or close processes according to the current Socket event.
  • the Web task will be in the state of waiting for the semaphore, until the required semaphore, the Web task can be activated again, continue to process the connection, read, Write, close, etc.
  • the Socket communication mechanism based on the Rex system uses an asynchronous, non-blocking Socket. Therefore, the semaphore mechanism does not have a mechanism to wait for a timeout. The task does not wait for the desired semaphore and waits for it to be activated.
  • the present invention provides a Socket processing method for a web server, and the web server is based on a platform that provides an asynchronous, non-blocking Socket.
  • the Socket processing method includes:
  • Step 21 Listening for a client request of the web server port
  • Step 22 Register a Socket event by an asynchronous selection operation according to the intercepted client request.
  • Step 23 Determine whether the Socket event is a READ event and/or a WRITE event, and obtain a judgment result
  • Step 24 When the judgment result indicates that the Socket event is a READ event and/or a WRITE event, time is turned on;
  • Step 25 After the timing reaches a preset threshold, the web task does not receive the bottom layer of the Socket.
  • the second semaphore is sent to the web task, so that the web task can be activated, and the corresponding process is processed according to the Socket event.
  • the client request to listen to the web server port register the interested Socket event through the asynchronous operation according to the intercepted client request; determine whether the current Socket event is a READ event and/or a WRITE event, and obtain the judgment result; When it is a READ event and/or a WRITE event, the timing is turned on; when the timing reaches a preset threshold, when the web task still does not receive the first semaphore, the second semaphore is sent to the web task, so that The web task can be activated, and the corresponding process is processed according to the Socket event.
  • the above method designs a timer.
  • the timer sends a semaphore to the web task to activate the web task. Therefore, an exception occurs on the client.
  • the web server is still able to be accessed.
  • the above Socket processing method includes:
  • Step 26 When the waiting time reaches a preset threshold, the web task does not receive the first semaphore sent by the bottom layer of the Socket, and sends a second semaphore to the web task, so that the web task can be After the activation, and processing according to the Socket event, the Socket event is closed.
  • Register events of interest to Socket including ACCEPT, WRITE, READ, CLOSE events
  • the Socket Timer sends a semaphore to the Web task to activate the Web task.
  • the exception Socket is closed.
  • Step one continuously listening to the client request of port 80;
  • Step 2 Registering the Socket event of interest by asynchronously selecting, the Socket event includes an ACCEPT, WRITE, READ, CLOSE event;
  • Step 3 Determine what event is currently in the Socket event of interest. If it is an ACCEPT or CLOSE event, perform step 5. Otherwise, perform step four;
  • Step 4 Wait for the underlying semaphore of the Socket, the Web task hangs, and perform step 6.
  • Step 5 The event of interest to the Socket is a READ and/or WRITE event, and the Socket Timer is set, waiting for the underlying semaphore or timer of the Socket to time out. The amount of semaphore sent, the web task hangs, and step 7 or step 8 is performed;
  • Step 6 After the Socket listens to the client event, the Socket callback function is called. After the callback function matches the current Socket event, the semaphore activates the Web task, and then processes the accept or close process according to the current Socket event;
  • Step 7 Set the wait time to 2s, the timer does not expire in 2s.
  • the Socket callback function is called. After the callback function matches the current Socket event, the semaphore activates the Web task. And then process the read and / or write process according to the current Socket event; return to step two;
  • Step 8 The timer 2s times out.
  • the Socket Timer timer callback function sends a semaphore to the Web task to activate the Web task. Then initiate the Socket close process, closing the Socket of the current exception.
  • the embodiment of the present invention further provides a Socket processing apparatus, which is used in a Web server, and the Web server is based on an embedded Rex system.
  • the Socket processing apparatus includes:
  • a monitoring module configured to listen for a client request of the web server port
  • a registration module configured to register a Socket event by an asynchronous selection operation according to the monitored client request
  • a determining module configured to determine whether the Socket event is a READ event and/or a WRITE event, and obtain a determination result
  • a timing module configured to: when the judgment result indicates that the Socket event is a READ event and/or a WRITE event, start timing
  • a semaphore sending module configured to: when the timing reaches a preset threshold, the web task does not receive the first semaphore sent by the bottom layer of the Socket, and sends a second semaphore to the web task, so that the web task is Can be activated, and the corresponding process is processed according to the Socket event.
  • a Socket closing module configured to: when the waiting time reaches a preset threshold, when the web task does not receive the first semaphore sent by the Socket, send a second semaphore to the web task, so that the web The task can be activated, and after the processing of the corresponding process is performed according to the Socket event, the Socket event is closed.
  • the platform for providing an asynchronous, non-blocking Socket is an embedded Rex system.
  • the web server port is port 80.
  • the embodiment of the present invention further provides a web server, where the web server is based on a platform for providing an asynchronous, non-blocking Socket, including the Socket processing apparatus according to any one of the above items.
  • the web task when an abnormality occurs on the client, the web task is suspended because the semaphore is not received, the timing is started, the timing reaches a preset threshold, and the web task does not receive the first signal sent by the Socket. Sending a second semaphore to activate the web task, causing the web task to process the corresponding process according to the Socket event, and closing the abnormal Socket event, so that the client can re-initiate the connection with the web server to achieve continuous Access to the operation of the web server, ie the web server can still be accessed.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer And Data Communications (AREA)
  • Computer Security & Cryptography (AREA)

Abstract

Socket处理方法、装置和 Web服务器,所述 Socket处理方法,用于一 Web服务器,所述 Web服务器基于提供异步、非阻塞方式 Socket的平台,所述方法包括:监听所述 Web服务器端口的客户端请求;根据监听到的所述客户端请求,通过异步选择操作注册 Socket事件;判断所述 Socket事件是否为 READ事件和/或 WRITE事件,获得一判断结果;在所述判断结果指示所述 Socket事件为 READ事件和/或 WRITE事件时,开启计时;在所述计时达到预设阈值,所述 Web任务未收到 Socket底层发送的第一信号量时,发送第二信号量给所述 Web任务,使得所述 Web任务能够被激活,并根据所述 Socket事件进行对应流程的处理。本发明实施例可以在客户端发生异常时, Web服务器仍然能够被访问。

Description

一种 Socket处理方法、 装置和 Web服务器
技术领域
本发明涉及通信领域, 尤其涉及一种 Socket处理方法、 装置和 Web服 务器。 背景技术
基于浏览器的用户界面 (webUI ) 已经越来越广泛的替代了 PC侧 UI软 件应用于 uFi类设备和数据卡类设备中, 电脑、 手机等客户端自带的浏览器 通过访问 webUI可以方便快捷的对 uFi或数据卡的基本配置进行查询和修改。 webUI的应用必须基于 Web服务器, Web服务器的主要功能是提供网上信息 浏览服务,在建立 Web服务器和电脑、手机等客户端网络连接时使用的通信 技术称为 Socket。 然而, 嵌入式 Rex系统的 Socket通信机制不同于嵌入式 Linux 系统的 Socket机制, 它是一种该平台上特有的异步、 非阻塞方式的 Socket, 因此不同于同步、 阻塞方式的 Socket, 它本身没有超时机制, 因为 在正常情形下它根本不需要超时机制。
在实践过程中我们发现, 几乎所有的电脑和智能手机都可以通过自身的 浏览器很顺畅的访问 Web服务器, 但是苹果公司的某系列的 MAC本在访问 Web服务器时会出现一定问题: 当 MAC本的浏览器顺利打开 WebUI进行一 段时间的浏览或者操作之后, 会出现无法继续浏览或操作的问题。
经过分析, 问题的表象原因在于 Web任务等不到 Socket底层发送的信 号量而一直处于等待状态, 无法继续处理连接、 读、 写、 关闭等流程, 此时 Web服务器无法继续被客户端访问。进一步分析发现, Web任务等不到 Socket 底层发送的信号量是由于 Socket底层没有监听到客户端的任何 Socket事件。 通过抓取 80监听端口的 TCP包分析发现, 由于 MAC客户端的某种原因, 它不再向监听端口发送任何 Socket请求。 发明内容 本发明实施例的目的是提供一种 Socket处理方法、装置和 Web服务器, 在客户端发生异常时, Web服务器仍然能够被访问。
为实现上述目的, 本发明实施例提供了一种 Socket处理方法, 用于一 Web服务器, 所述 Web服务器基于提供异步、 非阻塞方式 Socket的平台, 所述 Socket处理方法包括:
监听所述 Web服务器端口的客户端请求;
根据监听到的所述客户端请求, 通过异步选择操作注册 Socket事件; 判断所述 Socket事件是否为 READ事件和 /或 WRITE事件,获得一判断 结果;
在所述判断结果指示所述 Socket事件为 READ事件和 /或 WRITE事件时, 开启计时;
在所述计时达到预设阔值, 所述 Web任务未收到 Socket底层发送的第 一信号量时, 发送第二信号量给所述 Web任务, 使得所述 Web任务能够被 激活, 并根据所述 Socket事件进行对应流程的处理。
上述的 Socket处理方法, 其中, 所述 Socket处理方法还包括:
在所述等待计时达到预设阔值, , 所述 Web任务未收到 Socket底层发 送的第一信号量时, 发送第二信号量给所述 Web任务, 使得所述 Web任务 能够被激活,并根据所述 Socket事件进行对应流程的处理后,关闭所述 Socket 事件。
上述的 Socket处理方法, 其中, 所述提供异步、 非阻塞方式 Socket的平 台为嵌入式 Rex系统。
上述的 Socket处理方法, 其中, 所述 Web服务器端口为 80端口。
为实现上述目的, 本发明实施例还提供了一种 Socket处理装置, 用于一 Web服务器, 所述 Web服务器基于嵌入式 Rex系统, 所述 Socket处理装置 包括:
监听模块, 设置为: 监听所述 Web服务器端口的客户端请求;
注册模块, 设置为: 根据监听到的所述客户端请求, 通过异步选择操作 注册 Socket事件;
判断模块,设置为:判断所述 Socket事件是否为 READ事件和 /或 WRITE 事件, 获得一判断结果;
计时模块,设置为: 在所述判断结果指示所述 Socket事件为 READ事件 和 /或 WRITE事件时, 开启计时;
信号量发送模块, 设置为: 在所述计时达到预设阔值, 所述 Web任务未 收到 Socket底层发送的第一信号量时, 发送第二信号量给所述 Web任务, 使得所述 Web任务能够被激活, 并根据所述 Socket事件进行对应流程的处 理。
上述的 Socket处理装置, 其中, 还包括:
Socket关闭模块, 设置为: 在所述等待计时达到预设阔值, , 所述 Web 任务未收到 Socket底层发送的第一信号量时, 发送第二信号量给所述 Web 任务, 使得所述 Web任务能够被激活, 并根据所述 Socket事件进行对应流 程的处理后, 关闭所述 Socket事件。
上述的 Socket处理装置, 其中, 所述提供异步、 非阻塞方式 Socket的平 台为嵌入式 Rex系统。
上述的 Socket处理装置, 其中, 所述 Web服务器端口为 80端口。
为实现上述目的, 本发明实施例还提供了一种 Web服务器, 所述 Web 服务器基于提供异步、 非阻塞方式 Socket的平台, 包括上述任意一项所述的 Socket处理装置。
本发明实施例中, 在客户端发生异常, Web任务由于接收不到信号量而 一直挂起时, 开启计时, 计时达到预设阔值, 所述 Web任务未收到 Socket 底层发送的第一信号量时, 发送第二信号量激活所述 Web任务, 使得所述 Web任务根据所述 Socket事件进行对应流程的处理, 并关闭异常 Socket事 件, 使得客户端可以重新发起跟 Web服务器端的连接, 实现持续访问 Web 服务器的操作, 即 Web服务器仍然能够被访问。 附图概述
图 1为相关技术中 Socket实现流程图;
图 2为本发明实施例中 Socket处理方法的流程示意图; 图 3为基于本发明实施例的 Socket实现流程图;
图 4为本发明实施例中 Socket处理装置的结构示意图。
本发明的较佳实施方式
下面首先介绍现有技术中 Socket实现的过程, 如图 1所示。
监听客户端请求;
根据监听到的客户端请求进行异步选择操作注册感兴趣的 Socket事件; Web任务会处于等待信号量的状态中, 即任务等待信号量时相当于任 务被
暂时挂起不进行任何活动;
等到信号量后, 激活 Web任务, Web任务根据当前的 Socket事件分别 处理 accept (连接 ) 、 read (读) 、 write (写)或 close (关闭) 流程。
通过上述过程可以看出,异步选择操作注册了感兴趣的 Socket事件之后, Web任务会处于等待信号量的状态中, 直到等到需要的信号量之后, Web任 务才能再次激活,继续处理连接、读、写、关闭等流程。基于 Rex系统的 Socket 通信机制釆用的是异步、 非阻塞方式的 Socket, 因此, 信号量机制没有等待 超时的机制, 任务等不到想要的信号量就会一直等待下去, 无法被激活。
为解决上述问题, 本发明是实例提供一种 Socket处理方法, 用于一 Web 服务器, 所述 Web服务器基于提供异步、 非阻塞方式 Socket的平台, 如图 2 所示, 所述 Socket处理方法包括:
步骤 21 , 监听所述 Web服务器端口的客户端请求;
步骤 22, 根据监听到的所述客户端请求, 通过异步选择操作注册 Socket 事件;
步骤 23 , 判断所述 Socket事件是否为 READ事件和 /或 WRITE事件, 获得一判断结果;
步骤 24 , 在所述判断结果指示所述 Socket 事件为 READ 事件和 /或 WRITE事件时, 开启计时;
步骤 25 , 在所述计时达到预设阔值, 所述 Web任务未收到 Socket底层 发送的第一信号量时, 发送第二信号量给所述 Web任务, 使得所述 Web任 务能够被激活, 并根据所述 Socket事件进行对应流程的处理。
监听 Web服务器端口的客户端请求; 根据监听到的客户端请求, 通过异 步操作注册感兴趣的 Socket事件; 判断当前的 Socket事件是否为 READ事 件和 /或 WRITE事件, 获得判断结果; 在当前 Socket事件为 READ事件和 / 或 WRITE事件时, 开启计时; 计时到达一预设的阔值, 此时 Web任务仍然 未收到所述第一信号量时,发送第二信号量给所述 Web任务,使得所述 Web 任务能够被激活, 并根据所述 Socket事件进行对应流程的处理。
上述方法通过设计一定时器,当 Web任务在预设阔值时间内都没有等到 Socket底层发送的信号量时, 通过定时器给 Web任务发送一个信号量激活 Web任务, 因此, 在客户端出现异常时, Web服务器仍然能够被访问。
由于客户端已经出现异常, Web 任务被激活之后需要立刻关闭当前的 Socket, 使得客户端可以重新发起跟 Web服务器端的连接, 实现持续访问 Web服务器的操作, 因此, 上述 Socket处理方法还包括:
步骤 26,在所述等待计时达到预设阔值, , 所述 Web任务未收到 Socket 底层发送的第一信号量时,发送第二信号量给所述 Web任务,使得所述 Web 任务能够被激活, 并根据所述 Socket事件进行对应流程的处理后, 关闭所述 Socket事件。
上述 Socket处理方法, 其中, 所述提供异步、 非阻塞方式 Socket的平台 为嵌入式 Rex系统。
上述 Socket处理方法, 其中, 所述 Web服务器端口为 80端口。
本发明实施例提供的 Socket实现流程分为:
注册 Socket感兴趣的事件(包括 ACCEPT, WRITE, READ, CLOSE 事件) ;
判断当前 Socket感兴趣事件;
当前 Socket感兴趣事件为 ACCEPT或 CLOSE事件时等待信号量; 当前 Socket感兴趣事件为 READ和 /或 WRITE事件时,设置 Socket Timer 定时器然后等待信号量;
定时器超时则由 Socket Timer给 Web任务发送信号量激活 Web任务; 异常 Socket关闭。
具体流程如图 3所示:
步骤一, 不断监听 80端口的客户端请求;
步骤二, 通过异步选择注册感兴趣的 Socket 事件, Socket 事件包括 ACCEPT, WRITE, READ, CLOSE事件;
步骤三, 判断当前感兴趣的 Socket事件是什么事件, 如果为 ACCEPT 或 CLOSE事件则执行步骤五。 否则执行步骤四;
步骤四, 等待 Socket底层发信号量, Web任务挂起, 执行步骤六; 步骤五, Socket感兴趣的事件为 READ和 /或 WRITE事件 ,设置 Socket Timer定时器, 等待 Socket底层信号量或定时器超时发送的信号量, Web任 务挂起, 执行步骤七或者步骤八;
步骤六, Socket底层监听到客户端的事件后, 调用 Socket的回调函数, 回调函数匹配了当前的 Socket事件之后, 发送信号量激活 Web任务, 然后 根据当前的 Socket事件处理 accept或 close流程;
步骤七,设置等待时间的阔值为 2s, 定时器没有到 2s超时, Socket底层 监听到客户端的事件后, 调用 Socket 的回调函数, 回调函数匹配了当前的 Socket事件之后, 发送信号量激活 Web任务, 然后根据当前的 Socket事件 处理 read和 /或 write流程; 返回步骤二;
步骤八, 定时器 2s超时, 由 Socket Timer定时器回调函数给 Web任务 发送一个信号量激活 Web任务。 然后发起 Socket close流程, 关闭当前这个 异常的 Socket。
本发明实施例还提供了一种 Socket处理装置, 用于一 Web服务器, 所 述 Web服务器基于嵌入式 Rex系统, 如图 4所示, 所述 Socket处理装置包 括:
监听模块, 用于监听所述 Web服务器端口的客户端请求;
注册模块, 用于根据监听到的所述客户端请求, 通过异步选择操作注册 Socket事件;
判断模块,用于判断所述 Socket事件是否为 READ事件和 /或 WRITE事 件, 获得一判断结果; 计时模块, 用于在所述判断结果指示所述 Socket事件为 READ事件和 / 或 WRITE事件时, 开启计时;
信号量发送模块, 用于在所述计时达到预设阔值, 所述 Web任务未收到 Socket底层发送的第一信号量时,发送第二信号量给所述 Web任务,使得所 述 Web任务能够被激活, 并根据所述 Socket事件进行对应流程的处理。
上述的 Socket处理装置, 其中, 还包括:
Socket关闭模块, 用于在所述等待计时达到预设阔值, , 所述 Web任务 未收到 Socket底层发送的第一信号量时,发送第二信号量给所述 Web任务, 使得所述 Web任务能够被激活, 并根据所述 Socket事件进行对应流程的处 理后, 关闭所述 Socket事件。
上述的 Socket处理装置, 其中, 所述提供异步、 非阻塞方式 Socket的平 台为嵌入式 Rex系统。
上述的 Socket处理装置, 其中, 所述 Web服务器端口为 80端口。
本发明实施例还提供了一种 Web服务器, 所述 Web服务器基于提供异 步、 非阻塞方式 Socket的平台, 包括上述任意一项所述的 Socket处理装置。
以上所述仅是本发明的优选实施方式, 应当指出, 对于本技术领域的普 通技术人员来说, 在不脱离本发明原理的前提下, 还可以做出若干改进和润 饰, 这些改进和润饰也应视为本发明的保护范围。
工业实用 4生
本发明实施例中, 在客户端发生异常, Web任务由于接收不到信号量而 一直挂起时, 开启计时, 计时达到预设阔值, 所述 Web任务未收到 Socket 底层发送的第一信号量时, 发送第二信号量激活所述 Web任务, 使得所述 Web任务根据所述 Socket事件进行对应流程的处理, 并关闭异常 Socket事 件, 使得客户端可以重新发起跟 Web服务器端的连接, 实现持续访问 Web 服务器的操作, 即 Web服务器仍然能够被访问。

Claims

权 利 要 求 书
1. 一种 Socket处理方法, 用于一 Web服务器, 所述 Web服务器基于 提供异步、 非阻塞方式 Socket的平台, 其中, 所述 Socket处理方法包括: 监听所述 Web服务器端口的客户端请求;
根据监听到的所述客户端请求, 通过异步选择操作注册 Socket事件; 判断所述 Socket事件是否为读 READ事件和 /或写 WRITE事件,获得一 判断结果;
在所述判断结果指示所述 Socket事件为 READ事件和 /或 WRITE事件时, 开启计时;
在所述计时达到预设阔值, 所述 Web任务未收到 Socket底层发送的第 一信号量时, 发送第二信号量给所述 Web任务, 使得所述 Web任务能够被 激活, 并根据所述 Socket事件进行对应流程的处理。
2. 如权利要求 1所述的 Socket处理方法, 其中, 还包括:
在所述等待计时达到预设阔值, , 所述 Web任务未收到 Socket底层发 送的第一信号量时, 发送第二信号量给所述 Web任务, 使得所述 Web任务 能够被激活,并根据所述 Socket事件进行对应流程的处理后,关闭所述 Socket 事件。
3. 如权利要求 1所述的 Socket处理方法, 其中, 所述提供异步、 非阻塞 方式 Socket的平台为嵌入式 Rex系统。
4. 如权利要求 1所述的 Socket处理方法, 其中, 所述 Web服务器端口 为 80端口。
5. 一种 Socket处理装置, 用于一 Web服务器, 所述 Web服务器基于嵌 入式 Rex系统, 其中, 所述 Socket处理装置包括:
监听模块, 设置为: 监听所述 Web服务器端口的客户端请求;
注册模块, 设置为: 根据监听到的所述客户端请求, 通过异步选择操作 注册 Socket事件;
判断模块, 设置为: 判断所述 Socket事件是否为读 READ事件和 /或写 WRITE事件, 获得一判断结果; 计时模块,设置为: 在所述判断结果指示所述 Socket事件为 READ事件 和 /或 WRITE事件时, 开启计时;
信号量发送模块, 设置为: 在所述计时达到预设阔值, 所述 Web任务未 收到 Socket底层发送的第一信号量时, 发送第二信号量给所述 Web任务, 使得所述 Web任务能够被激活, 并根据所述 Socket事件进行对应流程的处 理。
6. 如权利要求 5所述的 Socket处理装置, 其中, 还包括:
Socket关闭模块, 设置为: 在所述等待计时达到预设阔值, , 所述 Web 任务未收到 Socket底层发送的第一信号量时, 发送第二信号量给所述 Web 任务, 使得所述 Web任务能够被激活, 并根据所述 Socket事件进行对应流 程的处理后, 关闭所述 Socket事件。
7. 如权利要求 5所述的 Socket处理装置, 其中, 所述提供异步、 非阻塞 方式 Socket的平台为嵌入式 Rex系统。
8. 如权利要求 5所述的 Socket处理装置, 其中, 所述 Web服务器端口 为 80端口。
9. 一种 Web服务器,所述 Web服务器基于提供异步、非阻塞方式 Socket 的平台, 包括权利要求 5至 8中任意一项所述的 Socket处理装置。
PCT/CN2013/082305 2012-10-30 2013-08-26 一种Socket处理方法、装置和Web服务器 WO2014067327A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US14/438,681 US9871885B2 (en) 2012-10-30 2013-08-26 Socket processing method and device and web server
EP13851976.4A EP2899944B1 (en) 2012-10-30 2013-08-26 Socket processing method and device and web server

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2012104239934A CN102938783A (zh) 2012-10-30 2012-10-30 一种Socket处理方法、装置和Web服务器
CN201210423993.4 2012-10-30

Publications (1)

Publication Number Publication Date
WO2014067327A1 true WO2014067327A1 (zh) 2014-05-08

Family

ID=47697651

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/082305 WO2014067327A1 (zh) 2012-10-30 2013-08-26 一种Socket处理方法、装置和Web服务器

Country Status (4)

Country Link
US (1) US9871885B2 (zh)
EP (1) EP2899944B1 (zh)
CN (1) CN102938783A (zh)
WO (1) WO2014067327A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117290840A (zh) * 2023-09-07 2023-12-26 北京海泰方圆科技股份有限公司 浏览器审计方法、装置、计算机设备和存储介质

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102938783A (zh) * 2012-10-30 2013-02-20 中兴通讯股份有限公司 一种Socket处理方法、装置和Web服务器
CN103763156A (zh) * 2014-01-28 2014-04-30 中国移动(深圳)有限公司 网络测速方法及系统
CN105812345B (zh) * 2014-12-31 2019-08-23 广州市动景计算机科技有限公司 一种实现网页到客户端通信的方法及装置
CN107025096B (zh) * 2016-01-29 2020-05-26 滴滴(中国)科技有限公司 异步渲染模块的同步方法及系统
CN108108234A (zh) * 2017-12-06 2018-06-01 链家网(北京)科技有限公司 一种分布式任务管理方法及系统
US10528512B1 (en) * 2018-03-14 2020-01-07 Parallels International Gmbh Improving efficiency of asynchronous input/output operations based on observed performance
US10990280B1 (en) 2018-12-03 2021-04-27 Parallels International Gmbh Smart keyboard
CN111552901B (zh) * 2019-02-11 2022-09-06 福建省天奕网络科技有限公司 H5跨引擎客户端数据自动化更新的方法、存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101119363A (zh) * 2007-07-20 2008-02-06 南京联创科技股份有限公司 基于统一接口的内存数据库远程并发访问和界面管理方法
CN101551821A (zh) * 2009-05-19 2009-10-07 周佺喜 一种在网页中进行实时信息广播的方法
CN102196002A (zh) * 2010-03-17 2011-09-21 同济大学 一种基于数据流通信的网络控制系统
CN102420861A (zh) * 2011-11-29 2012-04-18 广州杰赛科技股份有限公司 服务器的消息监听方法、装置及系统
CN102938783A (zh) * 2012-10-30 2013-02-20 中兴通讯股份有限公司 一种Socket处理方法、装置和Web服务器

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2699305B1 (fr) * 1992-12-11 1995-01-13 Bull Sa Dispositif d'utilisation de fonctions de pseudo point de communication déportées (pseudo sockets).
US6678246B1 (en) 1999-07-07 2004-01-13 Nortel Networks Limited Processing data packets
US7421705B2 (en) 2003-10-30 2008-09-02 Sprint Communications Company L.P. System and method for asynchronous processing in COBOL
US8965864B2 (en) 2006-10-31 2015-02-24 Sap Se Method and system for efficient execution and rendering of client/server interactive applications
CN100530107C (zh) * 2007-03-02 2009-08-19 中国科学院声学研究所 基于io事件通知机制的单进程内容服务器装置及方法
US8006005B2 (en) * 2007-09-21 2011-08-23 Mitel Networks Corporation Centralized polling service
CN101290588B (zh) * 2008-03-07 2010-06-16 重庆邮电大学 一种微嵌入式实时任务调度器及调度方法
US8984102B2 (en) * 2009-02-20 2015-03-17 Gary Stephen Shuster Registration and use of patterns defined by expressions as domain names
CN102045654B (zh) 2009-10-10 2015-01-28 上海中兴通讯技术有限责任公司 异步socket通讯方法及采用该方法的手机定位系统
CN102158350B (zh) * 2011-02-12 2012-11-21 华为终端有限公司 一种移动宽带设备及管理移动宽带设备的方法
US8392627B2 (en) 2011-04-25 2013-03-05 Microsoft Corporation Adaptive semaphore
CN102202094A (zh) * 2011-05-13 2011-09-28 中兴通讯股份有限公司 一种基于http的业务请求处理方法及装置
CN102413133B (zh) * 2011-11-17 2014-07-02 曙光信息产业(北京)有限公司 一种时间可控的客户端服务器传输方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101119363A (zh) * 2007-07-20 2008-02-06 南京联创科技股份有限公司 基于统一接口的内存数据库远程并发访问和界面管理方法
CN101551821A (zh) * 2009-05-19 2009-10-07 周佺喜 一种在网页中进行实时信息广播的方法
CN102196002A (zh) * 2010-03-17 2011-09-21 同济大学 一种基于数据流通信的网络控制系统
CN102420861A (zh) * 2011-11-29 2012-04-18 广州杰赛科技股份有限公司 服务器的消息监听方法、装置及系统
CN102938783A (zh) * 2012-10-30 2013-02-20 中兴通讯股份有限公司 一种Socket处理方法、装置和Web服务器

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2899944A4 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117290840A (zh) * 2023-09-07 2023-12-26 北京海泰方圆科技股份有限公司 浏览器审计方法、装置、计算机设备和存储介质
CN117290840B (zh) * 2023-09-07 2024-03-15 北京海泰方圆科技股份有限公司 浏览器审计方法、装置、计算机设备和存储介质

Also Published As

Publication number Publication date
CN102938783A (zh) 2013-02-20
US20150271294A1 (en) 2015-09-24
EP2899944A1 (en) 2015-07-29
EP2899944A4 (en) 2015-07-29
EP2899944B1 (en) 2016-10-12
US9871885B2 (en) 2018-01-16

Similar Documents

Publication Publication Date Title
WO2014067327A1 (zh) 一种Socket处理方法、装置和Web服务器
EP2830044B1 (en) Instruction processing method, apparatus, and system
EP3248132B1 (en) Detection of malicious invocation of application program interface calls
JP6517370B2 (ja) 端末とネットワークデバイスとの間の相互作用のための方法及び端末
CN110072219A (zh) 用于无线接近配对的电子设备、方法和计算机可读介质
CN111416867A (zh) 不同设备间的消息处理方法、服务器和计算机存储介质
US20100077063A1 (en) System and method for emulating a computing device
KR101884548B1 (ko) 멀웨어의 추적 및 검출을 위한 시스템 및 방법
US9807177B2 (en) Session aware USB redirection for multi-server published applications
WO2018049971A1 (zh) 热点网络切换方法及终端
US9774660B2 (en) Method and system for seamless webpage browsing
CN110933075B (zh) 服务调用方法、装置、电子设备及存储介质
CN109120482A (zh) 监控应用程序使用流量的方法及装置
WO2015172283A1 (zh) 一种降低功耗的方法、装置及移动终端
CN108665595B (zh) 一种智能可视门禁控制系统
CN109889468B (zh) 网络数据的传输方法、系统、装置、设备及存储介质
WO2016070690A1 (zh) 实现终端设备上的网页和应用间通信的方法、装置和系统
KR100963876B1 (ko) 수신 서비스에 따른 휴대단말의 모드 제어 방법 및 장치
WO2019128586A1 (zh) 应用程序处理方法、电子设备、计算机可读存储介质
WO2021244519A1 (zh) Wi-Fi控制方法、装置及电子设备
US9876859B1 (en) Client session timeout with automatic refresh
WO2017101336A1 (zh) 快捷开关的控制方法及装置
WO2014206172A1 (zh) 移动设备中的非可信环境与可信环境之间的切换
CN113609107A (zh) 数据库管理方法、装置、电子设备及存储介质
US9032536B2 (en) System and method for incapacitating a hardware keylogger

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13851976

Country of ref document: EP

Kind code of ref document: A1

REEP Request for entry into the european phase

Ref document number: 2013851976

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2013851976

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 14438681

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE