Click to See Complete Forum and Search --> : Winsock2 Sockets w/o MFC


Koolski
May 20th, 2004, 05:16 PM
Hi,

I'm new to sockets and I read the other posts and took your advice and have gotten "Network Programing for Microsoft Windows" and am trying to work up a prototype for the project I'm currently working on based on concepts in the book. The particular problem I'm having is hopefully a simple problem that I'm just having a brain cramp on. When I try to compile (Visual Studio 2003) the following two lines (verbatim from the book)

GUID guidAcceptEx = WSAID_ACCEPTEX;
GUID guidGetAcceptExSockaddrs = WSAID_GETACCEPTEXSOCKADDRS;

I get the following errors:
error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
error C2059: syntax error : '{'
error C2059: syntax error : '}'
error C2143: syntax error : missing ';' before '}'
error C2059: syntax error : '}'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)

The compiler doesn't like the expansion of the #define of these, but I don't know how to get around this. Any suggestions? This is for my call to load the Winsock extension functions; the call is below.

rc = WSAIoctl(
pListenobj->Sock,
SIO_GET_EXTENSION_FUNCTION_POINTER,
&guidAcceptEx,sizeof(guidAcceptEx),
&pListenobj->lpfnAcceptEx,
sizeof(pListenobj->lpfnAcceptEx),
&Bytes,NULL,NULL);

kuphryn
May 20th, 2004, 06:17 PM
What header files did you include? Include mswsock.h.

Kuphryn

Koolski
May 21st, 2004, 10:30 AM
It doesn't make any difference if I include any one or any combination of the following.

#include "mswsock.h"
#include "Winsock2.h"
#include "ws2tcpip.h"

kuphryn
May 21st, 2004, 12:42 PM
Maybe it is a syntax error.

Kuphryn

Mathew Joy
May 22nd, 2004, 12:13 AM
Loading the extention functions is to avoid performance penalty. Doesn't mean that you have to load it like that every where. Try calling the function the normal way. So that you know the rest of the things are OK. Those things are necessary only for performace intrinsic and high load servers.

Koolski
May 24th, 2004, 09:35 AM
Apparently the compiler wasn't liking the fact that the variable that I was assigning the "WSAID_ACCEPTEX" was a member of a dialog class. Don't really understand that, but the solution of having a local variable is a simple solution.