|
What errors ?
I've never used it - i generall use AcceptEx with IOCP.
Without the ability to use it in an overlapped manner you will be limiting the scaleability of your server app.
I do find it interesting though, i'm going to add it as an option to my server code.
I'll let you know how it goes.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I'm actually fairly green in terms of Programming with winsock, and using intermediate programming steps such as these. Basically, I'm not rightly sure how to set up the callback function, or ANY callback function....
I'm thinking I'm getting a little warmer, do I just add:
int CALLBACK EXPORT WSAAccept()::ConditionFunc(IN LPWSABUF lpCallerId,
IN LPWSABUF lpCallerData,
IN OUT LPQOS lpSQOS,
IN OUT LPQOS lpGQOS,
IN LPWSABUF lpCalleeId,
OUT LPWSABUF lpCalleeData,
OUT GROUP FAR *g,
IN DWORD_PTR dwCallbackData)
{
//condition code
}
And that should work? I basically add this just like a normal function right now...to the tail end of my code getting a few syntax errors:
error C2061: syntax error : identifier 'WSAAccept'
error C2059: syntax error : ';'
error C2059: syntax error : ':'
Again, Callback functions are a fairly new concept for me, as is about everything to do with winsock
|
|
|
|
|
You're a little off there.
More like:
int CALLBACK ConditionFunc(
IN LPWSABUF lpCallerId,
IN LPWSABUF lpCallerData,
IN OUT LPQOS lpSQOS,
IN OUT LPQOS lpGQOS,
IN LPWSABUF lpCalleeId,
OUT LPWSABUF lpCalleeData,
OUT GROUP FAR *g,
IN DWORD_PTR dwCallbackData
) {
// condition code
}
...
SOCKET sockListen,
sockClient;
SOCKADDR_STORAGE addrClient;
int addrLen = sizeof(addrClient);
...
// MyData may be a structure or could be 'this' is called within a class
// it is passed unmodified as dwCallbackData in ConditionFunc
sockClient = WSAAccept(sockListen, &addrClient, &addrLen, ConditionFunc, &MyData);
...
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thanks again, I'm stumbling through this, though now I'm getting some very disconcerting warnings:
warning C4113: 'int (__stdcall *)(struct _WSABUF *,struct _WSABUF *,struct _QualityOfService *,struct _QualityOfService *,struct _WSABUF *,struct _WSABUF *,unsigned int *)' differs in paramet
er lists from 'int (__stdcall *)(struct _WSABUF *,struct _WSABUF *,struct _QualityOfService *,struct _QualityOfService *,struct _WSABUF *,struct _WSABUF *,unsigned int *,unsigned long )'
warning C4047: 'function' : 'unsigned long ' differs in levels of indirection from 'void *'
warning C4024: 'WSAAccept' : different types for formal and actual parameter 5
And my WSAAccept call is
socketClient = WSAAccept(listenSocket, (LPSOCKADDR)&SockAddr, &nLen,ConditionFunc,NULL);
Don't really care about the data at the moment, but it does build and link, so I'm not sure of the implications on the execution yet
oh and the
IN DWORD_PTR dwCallbackData
Had to be removed from the parameter listfor some strange reason otherwise I would get....
error C2146: syntax error : missing ')' before identifier 'dwCallbackData'
error C2081: 'DWORD_PTR' : name in formal parameter list illegal
error C2061: syntax error : identifier 'dwCallbackData'
error C2059: syntax error : ';'
error C2059: syntax error : ')'
error C2449: found '{' at file scope (missing function header?)
error C2059: syntax error : '}'
Thanks a lot, I really appreciate your effort...
|
|
|
|
|
FYI, get an unhandled exception trying to write memory 0 referenced from somewhere's else...heh dunno if you have a similar issue...
|
|
|
|
|
HEHEHE, I'm stumped by this, but that last arguement APPEARS to be a DWORD not a DWORD_PTR either that or there is something I'm missing to declare a DWORD_PTR, wouldn't it just be DWORD * ptrname?
|
|
|
|
|
Ok, the warnings are because you removed IN DWORD_PTR dwCallbackData from the callback function.
You can't just remove it, the function has to match what is specified.
Focus on finding why DWORD_PTR isn't valid.
I just tested:
int CALLBACK ConditionFunc(
LPWSABUF lpCallerId,
LPWSABUF lpCallerData,
LPQOS lpSQOS,
LPQOS lpGQOS,
LPWSABUF lpCalleeId,
LPWSABUF lpCalleeData,
GROUP FAR *g,
DWORD_PTR dwCallbackData
) {
return(CF_ACCEPT); // or, CF_REJECT, or CF_DEFER
}
// called within one of my socket class methods,
// so 'this' is pointer to my socket class instance.
// int len = 0;
// SOCKADDR *sa = ...;
SOCKET s = ::WSAAccept(sockHnd, sa, &len, ConditionFunc, (DWORD)this);
I compiled without warnings or errors.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
somebody would tell me how to change the CScrollBar control's color?
Thanks!
|
|
|
|
|
http://msdn.microsoft.com/msdnmag/issues/01/11/c/
or custom draw:
http://www.codeproject.com/miscctrl/XScrollBar.asp
|
|
|
|
|
i had resolved it following ur guidance.
thanks very much!
|
|
|
|
|
Hi!
I'm storing a certain path in a CAtlString class. The function i need to pass this path to however only likes char pointers. How do i get a char pointer from a Unicode CAtlString?
|
|
|
|
|
|
Thanks This solved all of my coding problems. Never knew the conversions where this easy .
|
|
|
|
|
Could someone point me to a good website that gives me some sample code on using bool variables in c++? Thanks.
Thanks!
|
|
|
|
|
huh ?
bool bIDontUnderstand;
bIDontUnderstand = true;
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I'm trying to understand the advantage of declaring a variable type bool? I'm a beginner, For example: How do I use a bool variable?
#include <iostream>
using namespace std;
int main()
{
bool a;
int b,c;
if(b == c)
cout << "huh";
return 0;
}
Thanks!
|
|
|
|
|
A bool is used when you want to store the (true/false) value of a condition, for later reference. For example:
bool bSystemWasOK = checkIfSystemIsOK();
...
if (bSystemWasOK)
doSomething();
...
if (bSystemWasOK)
doSomethingElse();
Storing the value of the check in bSystemWasOK saves you the effort of calling checkIfSystemIsOK() repeatedly. This example assumes that the system state continues to be OK throughout the execution of the code fragment.
Hope this helps.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I'm starting to see. The problem I'm working on is a magic square program.
r1 1 6 8
r2 5 7 3
r3 9 2 4
I'm comparing row totals to column totals to test for equality between rowsum[] and colsum[] arrays and storing the result in a bool variable. I'm having a hard time seeing how to loop through the comparisons and using the bool variable at the same time.
Thanks!
|
|
|
|
|
Magic/Diabolic squares... mmmm... that seems to be known here in CodeProject.. Take a look on this article: Magic Square[^].
Just wanted to help.
Have a nice day.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
Your link to the magic square example was exactly what I needed! You are a life saver.
Thanks!
|
|
|
|
|
I don't mean to discount your question, but that's a bit like asking for a pointer to a Math book that describes how to use numbers. Is there something specific you'd like to know?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
I download the .NET Framework Version 1.1 Redistributable Package in the station, but when I try to run a .NET C++ application I got an error message
"Application has generated an exception that could not be handled."
The same application runs fine in my development station which has the full Visual Studio .NET installed. (It was ver. 1.0, but I also downlod the .NET Framework Version 1.1 Redistributable Package and SDK 1.1 as well).
Does anyone know what else I have to do to run the application outside of the development station?
Thank you in advance for your help.
|
|
|
|
|
I found out that I have to download NET Framework Version 1.0 Redistributable Package to run the application. After I did that, it works fine.
|
|
|
|
|
So what you are saying is that an app written against the 1.0 framework will not run if the machine only has the 1.1 framework installed? Does the framework not have backwards compatibility? So any apps currently being targeted for the 1.1 framework will not work with the 2.0 framework?
Does that mean that we are going to have to distribute the 21MB+ framework with every app just to ensure that the version the app requires is on the target machine, or is MS going to distribute all old versions with the newer OSes? Sounds like a pile of BS and a good reason to continue avoiding .NET.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I don't think it is true for all apps. Obviously, if the app depended on some API present in 1.0 but has been changed in 1.1, it won't work. Here[^] is the list of all changes made to the API that might break 1.0 to 1.1
Regards
Senthil
My Blog
|
|
|
|