View Full Version : Network Socket Programming
Walsi
19th June 2007, 08:57
Hello!!
I am coding a little Network Client/Server Application. And now I have a little problem with the high byte and low byte order. I know that there are two commands.
hton()
ntoh()
But I doesn't know the right include file for them under Linux. Or is there another command for this operation under Linux. Or is there any function in Qt, which could help me??
Best Regards,
Walsi
high_flyer
19th June 2007, 09:13
EIDT:
After reading below I see what you mean, and realize my answer was on the wrong track.
Sorry.
Or is there any function in Qt, which could help me??
Have a look at:
Qt Network module (http://doc.trolltech.com/4.2/qtnetwork.html)
wysota
19th June 2007, 09:24
hton()
ntoh()
But I doesn't know the right include file for them under Linux. Or is there another command for this operation under Linux.
I think you meant htons(), htonl(), ntohl() and ntohs(). They are in <netinet/in.h>. Have you tried using the "apropos" command in your shell?
camel
19th June 2007, 09:49
Or is there any function in Qt, which could help me??
If you use Qt 4.3:
qFromBigEndian (http://doc.trolltech.com/4.3/qtglobal.html#qFromBigEndian)
qToBigEndian (http://doc.trolltech.com/4.3/qtglobal.html#qToBigEndian)
qFromLittleEndian (http://doc.trolltech.com/4.3/qtglobal.html#qFromLittleEndian)
qToLittleEndian (http://doc.trolltech.com/4.3/qtglobal.html#qToLittleEndian)
As far as I know, network byte order is big endian, so all you have to do is call
qFromBigEndian and qToBigEndian with your data, and you are set :-)
Walsi
19th June 2007, 10:04
Thanks for your inforamtion!
I am using Qt4.2 and so i solved the problem by using
include<netinet/in.h>
Many Thanks to you!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.