Results 1 to 5 of 5

Thread: Network Socket Programming

  1. #1
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Network Socket Programming

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Network Socket Programming

    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
    Last edited by high_flyer; 19th June 2007 at 11:02.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Network Socket Programming

    Quote Originally Posted by Walsi View Post
    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?

  4. The following user says thank you to wysota for this useful post:

    Walsi (19th June 2007)

  5. #4
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Network Socket Programming

    Quote Originally Posted by Walsi View Post
    Or is there any function in Qt, which could help me??
    If you use Qt 4.3:
    qFromBigEndian
    qToBigEndian
    qFromLittleEndian
    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 :-)

  6. The following user says thank you to camel for this useful post:

    Walsi (19th June 2007)

  7. #5
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Network Socket Programming

    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!

Similar Threads

  1. Can any One help me? - Socket Programming?
    By vinod in forum Qt Programming
    Replies: 6
    Last Post: 18th November 2009, 10:46
  2. Beginning network programming
    By Morea in forum Qt Programming
    Replies: 3
    Last Post: 29th May 2007, 20:39
  3. Qt Network Programming
    By Walsi in forum Qt Programming
    Replies: 5
    Last Post: 25th May 2007, 11:50
  4. Socket Programming Port53 QTcpSocket/QUdpSocket
    By patrik08 in forum General Programming
    Replies: 5
    Last Post: 10th May 2007, 17:59
  5. Network programming and the main thread
    By invictus in forum Qt Programming
    Replies: 5
    Last Post: 16th March 2007, 01:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.