Winsock help

Hi everyone i was following a winsock tutorial on youtube and i typed out the code but i seem to have came up with oneerror that ive been trying to fix but cannot. Would someone mind helping me?
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
39
40
41
42
#include <conio.h>
#include <stdio.h>

#include <WinSock2.h>
#include <Windows.h>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    long answer;
    WSAData wsaData;
    WORD DLLVERSION;
    DLLVERSION = MAKEWORD(2,1);
    answer=WSAStartup(DLLVERSION, &wsaData);
    
    SOCKADDR_IN addr;
    int addrlen=sizeof(addr);
    
    SOCKET sListen;
    SOCKET sConnect;
    
    sConnect=socket(AF_INET, SOCK_STREAM, 0);
    
    addr.sin_addr.s_addr=inet_addr("127.0.0.1");
    addr.sin_family=AF_INET;
    addr.sin_port=htons(1234);
    
    sListen=socket(AF_INET, SOCK_STREAM, 0);
    bind(sListen, (SOCKADDR*)&addr, sizeof(addr));
    listen(sListen, 50MAXCONN);
    
    for(;;)
    {
     cout << "Waiting for an incoming connection..." << endl;
     if(sConnect=accept(sListen, (SOCKADDR*)&addr, &addrlen))
     {
       cout << "A connection was found" << endl;                          
     }       
    }
}

the error that came up said
invalid suffix "MAXCONN" on integer constant
On line 32, what is "50MAXCONN" supposed to be?
A variable name cannot begin with a number.
Thanks guys i fixed it i had no idea what i was thinking
closed account (ozUkoG1T)
Just out of Question are you looking at IceT3e3a vidoes
yeah how did you know?
@Cyberwarfare
You should move lines 18-19
1
2
    SOCKADDR_IN addr;
    int addrlen=sizeof(addr);
into the while loop above accept().

Also, this
 
socket(AF_INET, SOCK_STREAM, 0);
should be
 
socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
closed account (ozUkoG1T)
Because i watched it too and ask IceT3e3a for help he will help you as well by the way you know UDP flooder tutorials i asked him to make it LOL.

Topic archived. No new replies allowed.