OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Host Name length in MAC


Post Reply New Thread Subscribe

 
Thread Tools
sjain
Guest
 
Posts: n/a

Hi,

What is the maximum host name length defined by the OS. i mean, i had defined a 100 bytes of array which stores the hostname of my OS. I am porting the code for various flavours of Unix( Linux, HP UX, Solaris, AIX) and now MAC. But on MAC, i faced this issue where my hostname length exceeded this value of 100 and i got this segmentation fault. merely increasing it to 256 runs me into more issues. so by hit and trial method i have ended up taking 156 as the value of the array which works fine with me. but i am not satisfied with this approach. There must be a maximum value defined by the OS itself that it assigns itself for the hostname, ( some form of macro), which will give me a better approach to solve the issue. If anybody has any idea regarding this, please let me know ASAP.

Thanks a lot in advance

Regards
Sjain
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
Many of these type of values can be found in the header files. So something like this may help you.

grep -i host /usr/include/*/*.h | grep -Ei '(size|length)'

It looks like there could be multiple answers. Which ever one you choose, you should try to use the variable in your code on all the platforums your coding for. You should only define your own lenght as a last option. This may be a case where you use DEFINES that are platform dependent, unless they all share the same variable name and include file.

Anyway, that is the extent of my C knowledge for this case.
QUOTE Thanks
sjain
Guest
 
Posts: n/a

Thanx for the help. It solved my purpose to an extent.
QUOTE Thanks

Post Reply New Thread Subscribe


« Uptime command | Editing the path »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Connecting to Mac from PC problem beetlejelly OS X - Operating System 11 08-23-2012 09:47 AM
iPod for Windows and Mac? MacAddikt iPod Hardware and Accessories 12 03-31-2007 09:33 AM
Window users that are MAC WANNA BE'S! jdoverkill Switcher Hangout 47 10-12-2006 02:48 PM
It's called a Mac iSheep Schweb's Lounge 22 10-13-2004 05:35 PM

All times are GMT -4. The time now is 03:07 PM.

Powered by vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?