converts a u_long from host to TCP/IP network byte order

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stephenvs
Forum Newbie
Posts: 1
Joined: Wed Apr 21, 2004 10:41 pm
Contact:

converts a u_long from host to TCP/IP network byte order

Post by stephenvs »

converts a u_long from host to TCP/IP network byte order (which is big-endian).
E.g (vc++)
lNow=4221114;
ulNetVal = htonl (lNow);
ulNetVal give result 3127394304

In Vc++ htonl function can converts a u_long from host to TCP/IP network byte order (which is big-endian)

In PHP, Is there is any way we can do a convertioin like above vc++ example

My wrong understanding, If i use pack function. i expect the answer like above, But it result like this
<?php echo pack("N", "4221007"); ?> This is the result @hO

What should i do in order to get the result like above,
i.e converts a u_long from host to TCP/IP network byte order (which is big-endian).
Post Reply