Winsock issues

I am programming a network application using Winsock. Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream> //DEBUGGING PURPOSES ONLY: DELETE THIS LINE WHEN FUNCTIONAL
#include <cstdlib>
#include <fstream>
#include <string.h>
#include <socket.h>

#pragma comment(lib, "ws2_32.lib")

char INC_DATA[];
char SOURCEBUFFER[];

int iReqWinsockVer = 2;

using namespace std;

void listen() {
	WSADATA wsaData;
	if (WSAStartup(MAKEWORD(iReqWinsockVer,0), &wsaData)==0) {
        // Check if major version is at least iReqWinsockVer
        if (LOBYTE(wsaData.wVersion) >= iReqWinsockVer) {
			int listen = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
			int bind( SOCKET listen, const struct SOCK_ADDR* SOCKADDR_IN, int STRLEN );
			int recvfrom( SOCKET listen, char INC_DATA[], 256, 0, char SOURCEBUFFER[], 32 );
        }
	WSACleanup();
	}
}

int main() {
	listen();
	return 0;
}


Here is socket.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//Socket.h
#pragma once
#include <iostream>
#include <winsock2.h>

using namespace std;

const int STRLEN = 256;

class Socket
{
    public:
        WSADATA wsaData;
        SOCKET LISTEN;
        SOCKET ACCEPTSOCKET;
        sockaddr_in ADDRESSES;
    public:
        Socket();
        ~Socket();
        bool SendData( char* );
        bool RecvData( char*, int );
        void CloseConnection();
        void GetAndSendMessage();
};

class ServerSocket : public Socket
{
    public:
        void Listen();
        void Bind( int port );
        void StartHosting( int port );
};

class ClientSocket : public Socket
{
    public:
        void ConnectToServer( const char *ipAddress, int port );
};


And here is my error message:
 
On line 28 : error C2059: syntax error : 'constant'


I have done several searches that have lead me to believe that there is something wrong with my class, But I cannot figure it out. What could be causing this error message?
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void listen() 
{
    WSADATA wsaData;
    if (WSAStartup(MAKEWORD(iReqWinsockVer,0), &wsaData)==0) 
    {
        // Check if major version is at least iReqWinsockVer
        if (LOBYTE(wsaData.wVersion) >= iReqWinsockVer) 
        {
            int listen = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
            int bind( SOCKET listen, const struct SOCK_ADDR* SOCKADDR_IN, int STRLEN );//******** ????
            int recvfrom( SOCKET listen, char INC_DATA[], 256, 0, char SOURCEBUFFER[], 32 );//******** ???
        }
    WSACleanup();
    }
}


What are those two lines???
The first is a function declaration not a function call.
The second is part declaration part function call.
Sorry, I was getting highly frustrated and trying things out to see what happened. Needless to say, that is not productive, so I am trying to figure out what is wrong before I smash something. I was adding const's and char's and int's and stuff all over the place
Topic archived. No new replies allowed.