The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Converting Binary decimal coded values to Ascii Values gaur.deepti UNIX for Advanced & Expert Users 3 04-02-2008 09:33 AM
Socket Programming socket soshell High Level Programming 2 06-29-2004 04:49 AM
currupted my hard drive xcaliber UNIX for Dummies Questions & Answers 5 01-19-2004 08:27 AM
socket mercutio UNIX for Dummies Questions & Answers 1 12-06-2001 12:43 PM
socket amin IP Networking 1 02-10-2001 12:45 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-16-2006
Registered User
 

Join Date: Sep 2005
Posts: 13
Stumble this Post!
Question Socket values getting currupted

hi
I am using socket programming to transfer my header object form linux machine to unix machine.
when i transfer the object at unix machine the long and int values are getting currupted . So i am getting gatbage values.
but if i am doing this same task for linux to linux machine the same code is woking

what could be the reason behind this grabage value .

please help.

Thankx :
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-16-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,795
Stumble this Post!
Endianess - big-endian vs little-endian byte order. You probably need to change the byte order on the receiving side.

Call noths and/or nothl to correct the problem.

See man ntohl for more information.
Reply With Quote
  #3 (permalink)  
Old 08-17-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 356
Stumble this Post!
http://beej.us/guide/bgnet/output/ht...s.html#convert
Reply With Quote
  #4 (permalink)  
Old 08-18-2006
Registered User
 

Join Date: Sep 2005
Posts: 13
Stumble this Post!
Quote:
Originally Posted by jim mcnamara
Endianess - big-endian vs little-endian byte order. You probably need to change the byte order on the receiving side.

Call noths and/or nothl to correct the problem.

See man ntohl for more information.


the problem is due to Endianess.
as one of the machine is linux therefore little-endian and other is AIX therefore big-endian.

can you please explain ntohs function or suggest some sites.

thankx
Reply With Quote
  #5 (permalink)  
Old 08-18-2006
Registered User
 

Join Date: Aug 2006
Posts: 69
Stumble this Post!
Dear Bhakti,

have you looked into the Beej's guide for network programing. he has explained very nicely. I just repeate the same for you.

ntohs ==> 'n' -> network
'h' -> host
's' -> small

So you can have other combinations also like ntohl, htons to name a few. I think now you can figure out what ntol must be doing.

regards
Apoorva Kumar
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0