Skip to content

Commit

Permalink
Fix StreamSocket on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 committed Feb 18, 2024
1 parent 9a91d0e commit ca56748
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scapy/automaton.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def select_objects(inputs, remain):
events.append(i)
if natives:
results = results.union(set(select.select(natives, [], [], remain)[0]))
if results:
# We have native results, poll.
remain = 0
if events:
# 0xFFFFFFFF = INFINITE
remainms = int(remain * 1000 if remain is not None else 0xFFFFFFFF)
Expand Down
7 changes: 7 additions & 0 deletions scapy/supersocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ def recv_raw(self, x=MTU):
# type: (int) -> Tuple[Optional[Type[Packet]], Optional[bytes], Optional[float]]
return self.basecls, self.ins.recv(x), None

if WINDOWS:
@staticmethod
def select(sockets, remain=None):
# type: (List[SuperSocket], Optional[float]) -> List[SuperSocket]
from scapy.automaton import select_objects
return select_objects(sockets, remain)


class StreamSocket(SimpleSocket):
"""
Expand Down

0 comments on commit ca56748

Please sign in to comment.