Question

I'm trying to create a TFTP in python over a existing UDP i have. In my server.py.

As of now I'm able to send requests to read (RRQ) and write (WRQ) to the server. However, then a Packet object (Created object to be sent over to the server) reaches the server, I'm unable to access it.

In server.py :

Packet =  (server_from_client.recv())
print Packet
print id(Packet)
print Packet.opCode

This produces this output :

('127.0.0.1', 53909)
recv done
<Packet.Packet object at 0x1e89f50>


42518000
Traceback (most recent call last):
File "servertest.py", line 16, in <module>
print Packet.opCode
AttributeError: 'str' object has no attribute 'opCode'

Why does it first tell me that it's a Packet.Packet object (which does have an opCode) and then say it's a 'str' object with no opCode ????

Any help will be appreciated.

Was it helpful?

Solution

Instead of sending the packet, your client side converts it to the string <Packet.Packet object at 0x1e89f50> and sends it over the wire. Use print type(Packet) and print repr(Packet) to confirm.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top