C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 03-16-2004, 01:17 AM   #1
Registered User
 
Join Date: Jan 2004
Posts: 2
big/little endian issues

I was reading about unix network programming when i found about the big/little endian problem. Im working on PC(as we know Intel-based processors are little-endian), and if i need to send multi-byte numbers over a network, i have to convert them to big-endian format. My question is this, in a certain way, affects the character strings too? if im going to transmit any string, do i have to convert it in some format in order to send it over a network?

Thanks in advance
armin_miewes is offline   Reply With Quote
Old 03-16-2004, 02:14 AM   #2
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,683
Quote:
NAME
htonl, htons, ntohl, ntohs − convert values between host and network
byte order

SYNOPSIS
#include <netinet/in.h>

uint32_t htonl(uint32_t hostlong);

uint16_t htons(uint16_t hostshort);

uint32_t ntohl(uint32_t netlong);

uint16_t ntohs(uint16_t netshort);
You should have these already
Then it doesn't matter whether your machine is big or little
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Endian Question carrotcake1029 C Programming 8 01-07-2009 03:51 PM
Big Endian Little Endian Complex- Converting Characters bd02eagle C Programming 3 07-11-2006 01:01 AM
Big and little endian Cactus_Hugger C Programming 4 10-12-2005 07:07 PM
Calculating Endian type at runtime (and adapting to it) JoshR C++ Programming 10 06-26-2005 11:27 AM
fopen, fwrite, and endian issues FireAndGlass C Programming 7 06-19-2004 07:51 AM


All times are GMT -6. The time now is 04:48 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22