|
Is there any particular reason why you don't want to save the remote address returned by AcceptEx() (using GetAcceptExSockaddrs() as you mentioned before)? It sounds to me like there's not much choice.
If you can find out how netstat does it, then that would be the way to go, but I'm not sure how it does it, so you'll have to a bit more investigation
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
>> Is there any particular reason why you don't want to save the remote address returned by AcceptEx() (using GetAcceptExSockaddrs() as you mentioned before)?
It bothers me at a very fundamental level to store state that i can get from a cheap function call.
>> It sounds to me like there's not much choice.
<sigh> at this point i expect you're right (was up until 2:30am looking for other workarounds - no joy).
I'll either derive a new socket class for accepted connections, add a peer address field and then overload my GetPeerAddr() method ... what a senseless waste, or go back to sync WSAAccept() (looking like the 'cleaner' solution).
...cmk
|
|
|
|
|
cmk wrote:
It bothers me at a very fundamental level to store state that i can get from a cheap function call.
What's the difference between you storing the address returned by AcceptEx() and referencing it at any time, and the sockets implementation storing the address returned by AcceptEx() and you calling a function to retrieve it. It sounds pretty similar to me, except that the first one is more efficient than the second.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
What's the difference between you storing the address returned by AcceptEx() and referencing it at any time, and the sockets implementation storing the address returned by AcceptEx() and you calling a function to retrieve it.
When i store the address i am duplicating what is already in memory somewhere, that is i am using twice as much memory to store the peer address as i should have to (once in the winsock lib, once in my code).
So when we talk about efficiency it is faster for me to access the address if i store it, but it is less memory if i can use the address that the winsock lib has. As we are talking about connections, if you have a server that deals with 1,000's of simultaneous connections this can add up (ok, not much, but enough that it bothers me ).
Anyways, i've already coded my work around.
Added an #ifdef CKNET_USE_ACCEPTEX that if enabled uses AcceptEx and adds a peer address field to my connection class, #ifndef then tie up one (or more) of the IOCP threads to sit in a loop waiting on accept(). I find both acceptable workarounds for now.
...cmk
|
|
|
|
|
Hi:
how to get the current windows system language name? I want to know if it is English or the other languages(such as chinese, japanese)
|
|
|
|
|
Check out the PRIMARYLANGID macro. I hope that helps you.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Look at the GetLocaleInfo() function, specifying either LOCALE_SYSTEM_DEFAULT or LOCALE_USER_DEFAULT for the first parameter.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Man, I wish I had heard about that function a year ago. Good job Ryan! Your replies never cease to amaze me. I truly learn a lot from your posts.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Toni78 wrote:
Your replies never cease to amaze me. I truly learn a lot from your posts.
so true.
~RaGE();
|
|
|
|
|
Thanks
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
|
You're welcome
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Can we get a handle or icon id of an item which has been inserted in to a ListCtrl?
Example: if we have two icons in our image list and we inserted 100 items in the list can we find out if item 30 has icon #1 displayed with it or icon #2 displayed with it
P.S we are assuming that a image list has been associated to the control.
|
|
|
|
|
If you're using MFC, do this:
LVITEM lvi;
lvi.mask = LVIF_IMAGE;
lvi.iItem = nItemIndex;
m_listCtrl.GetItem(&lvi);
If you're not using MFC, do it this way:
LVITEM lvi;
lvi.mask = LVIF_IMAGE;
lvi.iItem = nItemIndex;
SendMessage(hwndListCtrl, LVM_GETITEM, 0, (LPARAM)&lvi);
Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I create a dialog.
And it is not expected to be closed when pressing the "Esc" key.
How to solve this problem?
Thank you in advance
|
|
|
|
|
Try to override CDialog::OnCancel().
Something like
void CMyDialog::OnCancel() { return;}
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
It works well after I do as your directions.
|
|
|
|
|
I am glad that it works well. I would also consider kmaz's directions as well even though I have never tried (or for that matter of fact heard that approach [then again, I have a lot to learn]). But it sounds very interesting and probably is worth to try it.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
It seems very difficult
If by overriding the function, I want to do like below:
bool m_bEsc;
void CAbc::OnCancel()
{
if( !m_bEsc)
return;
else
CDialog::OnCancel();
}
bool A()//Some operations to keybord's actions
{
....
}
Do you think that can work well?
|
|
|
|
|
Aleon666 wrote:
bool m_bEsc;
void CAbc::OnCancel()
{
if( !m_bEsc)
return;
else
CDialog::OnCancel();
}
bool A()//Some operations to keybord's actions
{
....
}
I don't see a reason why that would not work. Somebody else correct me please if I am wrong. But you have to try it yourself.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Aleon666 wrote:
Do you think that can work well?
Yep. No problems
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I would create an accelorator, which would disable the esc key and let you give other key combos functions.
|
|
|
|
|
I am sorry
I don't understand "and let you give other key combos functions"
What's that meaning?
Can you tell me?
|
|
|
|
|
Aleon666 wrote:
I don't understand "and let you give other key combos functions"
What's that meaning?
He means that using an accelerator, you can make other key-combinations perform other operations, as well as preventing the dialog from closing. However, Toni78's solution is the best and easiest one.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|