Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Sockets WSA
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
Edited 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 at 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 at 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
0 Sergey Alexandrovich Kryukov 861
1 OriginalGriff 410
2 CPallini 255
3 Volynsky Alex 205
4 Richard Deeming 175
0 OriginalGriff 5,540
1 Sergey Alexandrovich Kryukov 4,668
2 CPallini 4,540
3 George Jonsson 3,102
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2014
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