Código
Public Function htons(ByVal lPort As Long) As Integer htons = ((((lPort And &HFF000000) \ &H1000000) And &HFF&) Or ((lPort And &HFF0000) \ &H100&) Or ((lPort And &HFF00&) * &H100&) Or ((lPort And &H7F&) * &H1000000) Or (IIf((lPort And &H80&), &H80000000, &H0)) And &HFFFF0000) \ &H10000 End Function
He hecho esta alternativa a htons@Ws2_32 para un Shell que estoy haciendo y he pensado que os seria util.
La alternativa la he hecho para quitarme la declaracion de esa API, que siempre puede ser algo sospechosa

Simplemente lo que hace la funcion es revertir el orden de bytes y devolver solo el Integer significante... Por ejemplo:
Citar
666 decimal = 00000029A hexadecimal
Se invierten los bytes de orden: 9A020000
Y se devuelve el Integer (2 BYTES) mas significante, 9A02
Se invierten los bytes de orden: 9A020000
Y se devuelve el Integer (2 BYTES) mas significante, 9A02
Referencias:
Código:
http://www.xbeat.net/vbspeed/c_SwapEndian.htm
http://www.xbeat.net/vbspeed/c_HiWord.htm
Saludos
