开发者

python sockets, request.recv and signals

i have a question because i am fairly new to python, socket programming and signals. i have written a python socket server that forks a new process to handle requests for every client that connects to a certain port. I have caught the ctrl+c signal and closed开发者_如何学JAVA my database connections should the the server get such signal.

Since i am testing my server using the netcat command my question is: if one uses CTRL+C to terminate the client connection that is running in a bash window, can the server catch that SIGINT signal and act upon it ? or is it that because the client being a totally different program (my case is the netcat command) is the only one that can receive the SIGINT signal ?

Can the server receive a SIGINT command should the client be keyboardInterrupted ?

Thank you in advance for any information about this.


Signals exist in their own process: a signal raised in a client process won't be known about by the server process and vice versa. Your options are either to have one process tell the other that it is being terminated, or just wait for the other side to notice that the connection has been dropped (which, if you're using TCP/IP, will come from a failed socket operation on the given socket).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜