I see some physical address structure is defined like this:
typedef union {
struct {
ULONG LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} PHYSICAL_ADDRESS;
I don't understand why the high part is defined as signed type... Can anyone give an explanation?
Various structures are used in Unix Socket Programming to hold information about the address and port, and other information. Most socket functions require a pointer to a socket address structure as an argument. Structures defined in this chapter are related to Internet Protocol Family.
A socket connecting to the network is created at each end of the communication. Each socket has a specific address. This address is composed of an IP address and a port number. Socket are generally employed in client server applications.
An IPv4 socket address structure, commonly called an "Internet socket address structure," is named sockaddr_in and is defined by including the <netinet/in. h> header.
The number is signed to make math on it make more sense. If you subtract the address 123 from 456, you expect to get the address 333, right? So if you subtract 456 from 123, you expect to get -333, not 18,446,744,073,709,551,283, right? That's why addresses are signed.
The reason only the high part is signed is that a number only has one sign bit, and it's always the highest (most-significant) bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With