SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 412 | Next

Shon Harris, Allen Harper, Chris Eagle, and Jonathan Ness

"Gray Hat Hacking, Second Edition"

The
finer details of Linux socket programming are beyond the scope of this book, but here
goes the short version. Buckle up again!
C Program to Establish a Socket
In C, the following header files need to be included into your source code to build
sockets:
#include //libraries used to make a socket
#include //defines the sockaddr structure
The first concept to understand when building sockets is byte order.
IP Networks Use Network Byte Order
As we learned before, when programming on Linux systems, we need to understand that
data is stored into memory by writing the lower-order bytes first; this is called littleendian
notation. Just when you got used to that, you need to understand that IP networks
work by writing the high-order byte first; this is referred to as network byte order. In
practice, this is not difficult to work around. You simply need to remember that bytes
will be reversed into network byte order prior to being sent down the wire.
The second concept to understand when building sockets is the sockaddr structure.
sockaddr Structure
In C programs, structures are used to define an object that has characteristics contained
in variables. These characteristics or variables may be modified and the object may be
passed as an argument to functions.


Pages:
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424