Skip to content

Commit

Permalink
ADD: revert to use addr
Browse files Browse the repository at this point in the history
  • Loading branch information
T-K-233 committed Dec 27, 2023
1 parent 2a2965c commit e494cac
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cc/udp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@


class UDPRx:
"""
@param addr: address to listen on
"""
def __init__(self, addr=("0.0.0.0", 8000)):
self.addr = addr

Expand Down Expand Up @@ -33,12 +36,15 @@ def recv(self, buffer_size=1024, timeout=None):


class UDPTx:
def __init__(self, target_addr=("0.0.0.0", 8000)):
self.target_addr = target_addr
"""
@param addr: address of target host
"""
def __init__(self, addr=("0.0.0.0", 8000)):
self.addr = addr

self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

print("UDP Tx is initialized:", self.target_addr)
print("UDP Tx is initialized:", self.addr)

def stop(self):
self._sock.close()
Expand All @@ -49,6 +55,6 @@ def sendDict(self, data):
self.send(buffer)

def send(self, buffer):
self._sock.sendto(buffer, self.target_addr)
self._sock.sendto(buffer, self.addr)


0 comments on commit e494cac

Please sign in to comment.