Click here to Skip to main content
12,946,816 members (52,353 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Ok.. so I made a server-socket based tetris game using the winsock2 Windows Socket API. I finished the program, it works fine, and i actually have no problem in setting up the socket or the WSA. But there's something i don't understand from the winsock2 API. The function MAKEWORD(BYTE bLow,BYTE bHigh).
What does it mean? Can anyone give me a good example of what does this function mean.
I've looked up for the macro, i don't have any problem understanding it. the only problem is i don't understand the concept of MAKEWORD or what is it for.
can anyone help me?
Any help would be really appreciated.
Posted 3-Jan-13 22:37pm
Updated 3-Jan-13 22:39pm
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The documentation [^] says it all: "Creates a WORD value by concatenating the specified (byte) values".
It is just an auxiliary macro, useful if you have two bytes and need to 'glue' them in a word. A similar macro (whose usefulness is apparent) is RGB[^].
  Permalink  
Comments
Marcus Kramer 4-Jan-13 16:43pm
   
+5.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

A BYTE contains 8 (usable) bits. In this context, a WORD contains 16 bits or 2 BYTEs. These can be represented as

           +--------+--------+
2 BYTEs    |bbbbbbbb|bbbbbbbb|
           +--------+--------+
1 WORD     +wwwwwwww wwwwwwww|
           +--------+--------+

You can build a WORD out of 2 BYTEs. There is an upper BYTE and lower BYTE. The macro you describe does exactly that.
  Permalink  
Comments
Marcus Kramer 4-Jan-13 16:43pm
   
+5. Well explained.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 4,919
CHill60 3,235
Maciej Los 2,508
Jochen Arndt 1,935
ppolymorphe 1,795


Advertise | Privacy | Mobile
Web02 | 2.8.170518.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100