In reply to rustyguru:
Please go back and edit your post to use code tags making your code easier to read.
We don’t know what packet_type is.
Pleas explain your problem in terms of what you expect to see happend versus what is actually happening.