socket functions...

This is a discussion on socket functions... within the C Programming forums, part of the General Programming Boards category; i am using all of these functions in some of my codes but actually dont know what they are exactly ...

  1. #1
    template<typename T> threahdead's Avatar
    Join Date
    Sep 2002
    Posts
    214

    socket functions...

    i am using all of these functions in some of my codes but actually dont know
    what they are exactly doing.
    Code:
    htons() -- "Host to Network Short"
    
    htonl() -- "Host to Network Long"
    
    ntohs() -- "Network to Host Short"
    
    ntohl() -- "Network to Host Long"
    there are others like atoi()....
    can someone explain me how these functions work/what they do?

    thanks

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    98
    These functions are used to overcome byte-ordering differences which may occur between the network protocol (e.g. TCP/IP) and the OS.

    byte ordering relates to whether or not the first bit in an 8-bit byte is the large bit or the small bit (Big-Endian or Little-Endian). As you say, the function acronyms relate to the following...

    H = Host
    N = Network
    L = Long ( really a 32-bit value )
    S = Short ( really a 16-bit value )

  3. #3
    template<typename T> threahdead's Avatar
    Join Date
    Sep 2002
    Posts
    214
    its clearer to me now thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Non-blocking socket connection problem
    By cbalu in forum Linux Programming
    Replies: 25
    Last Post: 06-03-2009, 03:15 AM
  2. socket programming question, closing sockets...
    By ursula in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-31-2009, 06:17 PM
  3. Is it legal to have functions within functions?
    By Programmer_P in forum C++ Programming
    Replies: 13
    Last Post: 05-26-2009, 12:21 AM
  4. Re-enabling functions
    By Hunter2 in forum Networking/Device Communication
    Replies: 7
    Last Post: 02-02-2005, 12:49 PM
  5. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21