Click here to Skip to main content
14,303,059 members

ATL / WTL / STL

 
QuestionProgram for implementing Quine McCluskey's method for 8,9 or 10 variables Pin
Member 1103323724-Aug-14 16:38
memberMember 1103323724-Aug-14 16:38 
AnswerRe: Program for implementing Quine McCluskey's method for 8,9 or 10 variables Pin
Richard MacCutchan24-Aug-14 21:52
protectorRichard MacCutchan24-Aug-14 21:52 
Questionunexpected address value in WSABUF ( RESOLVED ) Pin
bkelly1311-Aug-14 13:34
memberbkelly1311-Aug-14 13:34 
QuestionRe: unexpected address value in WSABUF Pin
Richard MacCutchan11-Aug-14 21:25
protectorRichard MacCutchan11-Aug-14 21:25 
AnswerRe: unexpected address value in WSABUF Pin
bkelly1312-Aug-14 1:51
memberbkelly1312-Aug-14 1:51 
GeneralRe: unexpected address value in WSABUF Pin
Richard MacCutchan12-Aug-14 3:36
protectorRichard MacCutchan12-Aug-14 3:36 
GeneralRe: unexpected address value in WSABUF Pin
bkelly1312-Aug-14 5:42
memberbkelly1312-Aug-14 5:42 
GeneralRe: unexpected address value in WSABUF Pin
Richard MacCutchan12-Aug-14 20:48
protectorRichard MacCutchan12-Aug-14 20:48 
typedef struct __WSABUF { u_long len; char FAR *buf; } WSABUF, *LPWSABUF;

You read the above as struct __WSABUF declares a structure whose contents are declared within the braces following. The typedef specifier creates synonyms for the following declaration, which in their turn can be modified types. In this case WSABUF is a synonym for the preceding structure declaration. *LPWSABUF is a synonym for a pointer to the structure: the preceding asterisk tells us that it is a pointer.
So the declaration
LPWSABUF  p_lpwsabuf_array[ TCP_SERVER_PACKET_BUFFER_SIZE ];

declares an array of pointers. However according to the documentation for WSASend[^], the second parameter is a pointer to an array of WSABUF structures, not pointers, so it should be declared, and initialised something like:
WSABUF  wsabuf_array[ TCP_SERVER_PACKET_BUFFER_SIZE ];

// ...

for (int i = 0; i < TCP_SERVER_PACKET_BUFFER_SIZE; ++i)
{
    wsabuf_array[i].len = 16;  // set the length of the buffer in this structure element
    wsabuf_array[i].buf = new char[16]; // allocate a character array and save its address in the structure
}

Then when you need to use a pointer to the array on a call to WSASEND you just use the array name, which the compiler converts to a pointer to the first element thus:
int result = WSASend(socket, wsabuf_array, count, ... etc)

Does that make sense?
GeneralRe: unexpected address value in WSABUF Pin
bkelly1313-Aug-14 1:53
memberbkelly1313-Aug-14 1:53 
GeneralRe: unexpected address value in WSABUF Pin
Richard MacCutchan12-Aug-14 4:54
protectorRichard MacCutchan12-Aug-14 4:54 
AnswerMoving on to WSASend Pin
bkelly1313-Aug-14 10:33
memberbkelly1313-Aug-14 10:33 
GeneralRe: Moving on to WSASend Pin
Richard MacCutchan13-Aug-14 22:08
protectorRichard MacCutchan13-Aug-14 22:08 
GeneralRe: Moving on to WSASend Pin
bkelly1314-Aug-14 3:19
memberbkelly1314-Aug-14 3:19 
GeneralRe: Moving on to WSASend Pin
Richard MacCutchan14-Aug-14 3:30
protectorRichard MacCutchan14-Aug-14 3:30 
GeneralRe: Moving on to WSASend Pin
bkelly1314-Aug-14 3:52
memberbkelly1314-Aug-14 3:52 
QuestionCreating Classes in VS 2013 Pin
Bram van Kampen9-Aug-14 15:22
memberBram van Kampen9-Aug-14 15:22 
AnswerRe: Creating Classes in VS 2013 Pin
Richard Andrew x649-Aug-14 17:50
professionalRichard Andrew x649-Aug-14 17:50 
Questionerror - cannot convert parameter 3 from 'char [1024]' to 'wchar_t *' Pin
Swap95-Aug-14 21:40
memberSwap95-Aug-14 21:40 
AnswerRe: error - cannot convert parameter 3 from 'char [1024]' to 'wchar_t *' Pin
Richard MacCutchan5-Aug-14 22:34
protectorRichard MacCutchan5-Aug-14 22:34 
AnswerRe: error - cannot convert parameter 3 from 'char [1024]' to 'wchar_t *' Pin
Subrat 470826612-Sep-14 15:15
memberSubrat 470826612-Sep-14 15:15 
Questionhow to let menu auto show next item when mouse on the bottom arrow of menu Pin
fengforky9-Jul-14 22:53
memberfengforky9-Jul-14 22:53 
AnswerRe: how to let menu auto show next item when mouse on the bottom arrow of menu Pin
Richard MacCutchan9-Jul-14 23:34
protectorRichard MacCutchan9-Jul-14 23:34 
QuestionWCHAR, wstring, initializing and accessing them (RESOLVED) Pin
bkelly131-Jul-14 10:13
memberbkelly131-Jul-14 10:13 
AnswerRe: WCHAR, wstring, initializing and accessing them Pin
Richard MacCutchan2-Jul-14 5:38
protectorRichard MacCutchan2-Jul-14 5:38 
Generalnarrowing the focus a bit Pin
bkelly132-Jul-14 9:59
memberbkelly132-Jul-14 9:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.