The code simply takes the last 2 bytes from the array and uses them as a big-endian number.
Usually in network packets the port number is transferred in big-endian (meaning the byte with the lower address is more significant).
The code takes byte number i+4 and uses it as the MSB and byte i+5 as the LSB of the port number.
Barak Schiller
2009-06-20 11:41:03