954,153 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

wsaData : undeclared identifier

i get a error that i cant figure out any help?

void main()
{
// Initialize WinSock
int wsaret=WSAStartup(0x101,&wsaData);
if(wsaret)
return;
//Create the SOCKET

SOCKET conn;
conn=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(conn==INVALID_SOCKET)
return;

//clean up mess
closesocket(conn);
WSACleanup();
}

i get this error:

wsaData : undeclared identifier

any help

fakespike
Junior Poster in Training
58 posts since Jul 2003
Reputation Points: 10
Solved Threads: 0
 

Hard to say exactly, as you don't appear to have posted the complete compileable code that exhibits your problem.

> void main()
>{
>// Initialize WinSock
> int wsaret=WSAStartup(0x101,&wsaData);

You use wsaData in the line above. Where is it declared? Is it somewhere before main() is called, or does it exist in a header file somewhere that is (or is supposed to be) included by your program?

Bob
Junior Poster
Team Colleague
129 posts since Feb 2003
Reputation Points: 15
Solved Threads: 2
 

This was part of a duplicate post. More information is available at [thread]1183[/thread]

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 

I came across the following code that you posted in a different thread. Here wsaData is declared in the line I've highlighted:

#include <winsock.h>
#include <wsipx.h>
#include <wsnwlink.h>
#include <stdio.h>

int main()
{
////////////////
// Initialize windows sockets API.
//
WORD wVersionRequested = MAKEWORD(1, 1);
<strong>WSADATA wsaData;</strong>
if (WSAStartup(wVersionRequested, &wsaData)) {


Compare that with your post in this thread.

Bob
Junior Poster
Team Colleague
129 posts since Feb 2003
Reputation Points: 15
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You