class RxPServer: def __init__(self, ip, port, window=1024): self.ip = ip self.port = port self.window = 1024 self.socket = RxPSocket(ip, port, window) def setWindow(self, window): logging.debug("[DEBUG] Server set window called.") return def acceptIncomingConnections(self): logging.debug("[DEBUG]: RxPServer is accepting incoming connections-run from the RxPServer class") # method stub while True: #TODO: try except goes here self.socket.listen() if not self.handleConnection(): break def handleConnection(self): data = self.socket.receive() if data is None: return False logging.debug("[DEBUG]I got"+data) return True def sendClientFile(filename): logging.debug("[DEBUG]RxPServer-Going to send client this file: " + filename) def post(filename): logging.debug("[DEBUG]RxPServer-Going to get this file from client: " + filename)
class RxPClient: def __init__(self, ip, port): self.ip = ip self.port = port if self.ip == "": self.ip = "127.0.0.1" if self.port == "": self.port = random.randint(30000, 33000) self.socket = RxPSocket(self.ip, self.port, 1024) def connect(self, NetEmu_IP, NetEmu_Port): logging.debug("[DEBUG] RxP client is trying to connect to netEmu. Ran from the RxPClient class") self.socket.connect(NetEmu_IP, NetEmu_Port) # self.socket.send("Hello world!") # method stub for connect called from the client side # TODO: Implementing this command before RxPSocket has been coded. Make sure this works after coding that up. # data, recipient_ip, recipient_port def post(self, data): # recipient_ip = self.address[0] # recipient_port = self.address[1] recipient_ip = self.ip recipient_port = self.port # TODO: Implement send(data, recipient_ip, recipient_port) in RxPSocket class # super.send(data, recipient_ip, recipient_port) def get(self, filename): print("Get called in RxPClient.py. wants file: " + filename) packetData = "GET:" + filename # TODO: The following is broken. self.socket.receive(filename) def setWindow(self, window): return ""
def __init__(self, ip, port): self.ip = ip self.port = port if self.ip == "": self.ip = "127.0.0.1" if self.port == "": self.port = random.randint(30000, 33000) self.socket = RxPSocket(self.ip, self.port, 1024)
def __init__(self, ip, port, window=1024): self.ip = ip self.port = port self.window = 1024 self.socket = RxPSocket(ip, port, window)
def createRxPSocket(ip_address, port_number): socket = RxPSocket() source_address = (ip_address, port_number) socket.bind(source_address) return socket