Socket values getting currupted


 
Thread Tools Search this Thread
Top Forums Programming Socket values getting currupted
# 1  
Old 08-16-2006
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 :
# 2  
Old 08-16-2006
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.
# 3  
Old 08-18-2006
# 4  
Old 08-18-2006
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
# 5  
Old 08-18-2006
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. Smilie

regards
Apoorva Kumar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting odd values to even values(or vice-versa) located in a column

Hello All, I have a below data in a .csv file where all rows where col1 is A, col2 is odd numbers, similarly even numbers for all rows where col1 is B. Note that my data has some other columns(not shown here) too (around 100) after col2. Tool,Data A,1 A,3 A,5 .... so on B,2 B,4 .... ... (4 Replies)
Discussion started by: ks_reddy
4 Replies

2. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

3. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies

4. Programming

Error with socket operation on non-socket

Dear Experts, i am compiling my code in suse 4.1 which is compiling fine, but at runtime it is showing me for socket programming error no 88 as i searched in errno.h it is telling me socket operation on non socket, what is the meaning of this , how to deal with this error , please... (1 Reply)
Discussion started by: vin_pll
1 Replies

5. Programming

socket function to read a webpage (socket.h)

Why does this socket function only read the first 1440 chars of the stream. Why not the whole stream ? I checked it with gdm and valgrind and everything seems correct... #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include... (3 Replies)
Discussion started by: cyler
3 Replies

6. Shell Programming and Scripting

How to pick values from column based on key values by usin AWK

Dear Guyz:) I have 2 different input files like this. I would like to pick the values or letters from the inputfile2 based on inputfile1 keys (A,F,N,X,Z). I have done similar task by using awk but in that case the inputfiles are similar like in inputfile2 (all keys in 1st column and values in... (16 Replies)
Discussion started by: repinementer
16 Replies

7. Programming

which socket should socket option on be set

Hi all, On the server side, one socket is used for listening, the others are used for communicating with the client. My question is: if i want to set option for socket, which socket should be set on? If either can be set, what's the different? Again, what's the different if set option... (1 Reply)
Discussion started by: blademan100
1 Replies

8. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

9. Programming

Socket Programming socket

Hello, I actually try to make client-server program. I'm using SCO OpenServer Release 5.0.0 and when I try to compile my code (by TELNET) I've got this error : I'm just using this simple code : and I get the same error if I use : If someone can help me, Thanks (2 Replies)
Discussion started by: soshell
2 Replies

10. UNIX for Dummies Questions & Answers

currupted my hard drive

Hello, earlier tonight I was installing BETA version of Mandrake Linux 9.0 and I realised I needed to partition my drive. I tried making the partition within mandrake but ther wasnt an option within the mandrake setup. So i go into my WindowsXP and do the disk management option but there want a... (5 Replies)
Discussion started by: xcaliber
5 Replies
Login or Register to Ask a Question