Solved Defining FD_SETSIZE in .pro file
-
I want to increase the FD_SETSIZE to increase the number of sockets supported by select(..). According to the Microsoft, one can increase it by defining the FD_SETSIZE before <winsock2.h> or could add "-DFD_SETSIZE=128" as an option to the compiler command line for Microsoft C++.
I've tried all the below lines in .pro files but none of them seems to work.
DEFINES += _FD_SETSIZE=1500 DEFINES += FD_SETSIZE=1500 DEFINES += -DFD_SETSIZE=1500
I'm trying to avoid #IFDEF in every source file which includes <winsock2.h> therefore i'm trying to pass it to the compiler.
-
@pingal said in Defining FD_SETSIZE in .pro file:
I want to increase the FD_SETSIZE to increase the number of sockets supported by select(..)
Do you use
select
? Also having 1500 sockets in one process is a very dubious idea to begin with ... -
Yes, I'm using select(..) and i'm not handling 1500 clients at a time. I'm just setting the MAX_CLIENTs just to be on the safe-side.
How do i instruct the compiler in .pro file to include FD_SETSIZE limit ?
-
Provide the compile line you get from using
DEFINES += "FD_SETSIZE=1500"
Alternatively for the msvc compiler:*msvc*:QMAKE_CXXFLAGS+="/DFD_SETSIZE#1500"
-
"Provide the compile line you get from using DEFINES += "FD_SETSIZE=1500" "
Sorry, I didn't get this statement.
-
@pingal said in Defining FD_SETSIZE in .pro file:
DEFINES += "FD_SETSIZE=1500
Add this, build and then copy paste the compiler call, so we can see whether and how this define is passed to the compiler.
-
DEFINES += "FD_SETSIZE=1500" in .pro file produces below compile output:
C:/Qt/Tools/mingw810_64/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/user1/Desktop/Projects/QT projects/build-untitled6-Desktop_Qt_6_0_4_MinGW_64_bit-Debug' g++ -c -fno-keep-inline-dllexport -g -std=gnu++1z -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DFD_SETSIZE=1500 -D_WIN32_WINNT=0x0602 -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../untitled6 -I. -IC:/Qt/6.0.4/mingw81_64/include -IC:/Qt/6.0.4/mingw81_64/include/QtQuick -IC:/Qt/6.0.4/mingw81_64/include/QtOpenGL -IC:/Qt/6.0.4/mingw81_64/include/QtGui -IC:/Qt/6.0.4/mingw81_64/include/QtQmlModels -IC:/Qt/6.0.4/mingw81_64/include/QtQml -IC:/Qt/6.0.4/mingw81_64/include/QtNetwork -IC:/Qt/6.0.4/mingw81_64/include/QtCore -Idebug -IC:/VulkanSDK/1.0.51.0/Include -IC:/Qt/6.0.4/mingw81_64/mkspecs/win32-g++ -o debug\ClientResponse.o ..\untitled6\ClientResponse.cpp
In the compiler output, it is shown as "-DFD_SETSIZE=1500"
-
@pingal said in Defining FD_SETSIZE in .pro file:
In the compiler output, it is shown as "-DFD_SETSIZE=1500"
Which is correct, so you should search the error elsewhere, it's not that the macro isn't defined or has the wrong value. Probably this simply isn't supported anymore (as it appears to be some sort of legacy quick-fix).
-
#ifndef FD_SETSIZE #define FD_SETSIZE MaxClients #endif
Solved my problem, thanks