How epoll detect clientside close in Python?

后端 未结 10 599
清歌不尽
清歌不尽 2021-02-04 21:22

Here is my server

\"\"\"Server using epoll method\"\"\"

import os
import select
import socket
import time

from oodict import OODict

addr = (\         


        
10条回答
  •  一个人的身影
    2021-02-04 21:52

    I have another approach..

    try:
        data = s.recv(4096)
    except socket.error:
        if e[0] in (errno.EWOULDBLOCK, errno.EAGAIN): # since this is a non-blocking socket..
            return # no error
        else:
            # error
            socket.close()
    
    if not data: #closed either
        socket.close() 
    

提交回复
热议问题