|
Hi,
I am writing an app which requires some CSocket derived objects to be created and processed in seperate threads. All was going well until I made the release build, when I started getting the SOCKET NOTIFICATION SINK errors (I was using CSocket within the CWinThread object).
OK, so after looking for a reason, I discover that it is to do with the CSocket not having an owner window to handle the messages (or some such - still a bit vague about it) and that it's a bit of a bug.
My workaround at the moment is to create a hidden dialog from the thread and put the CSocket derived class in here. This works great, except I get the pesky dialog appearing in the task manager. Since I plan to have several threads running, this is all a bit tacky.
Anyone got any better ideas? or failing that, anyone knwo how I can hide these dialogs without hiding the main window?
BTW using VC++ 6.0
Many Thanks
|
|
|
|
|
I don't think the problem lies within CSocket, because there is absolutely no connection between a CSocket and a window.
It must be something you are doing in your derived class.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
I don't know if this is your problem, but I was having a problem yesterday with using a thread and CSocket. Microsoft has a confirmed bug in which certain members of CAsyncSocket don't get initialized correctly in a second thread (or something like that). The resolution was to put a call to the function I'm going to include below. This function can be a member of your class as long as you also make this static. Also this must be called before EVERY creation of a CSocket object in the second thread if you're doing it like I was in a loop.
void [YourClassName]::SocketThreadInit(void)
{
#ifndef _AFXDLL
#define _AFX_SOCK_THREAD_STATE AFX_MODULE_THREAD_STATE
#define _afxSockThreadState AfxGetModuleThreadState()
_AFX_SOCK_THREAD_STATE* pState = _afxSockThreadState;
if (pState->m_pmapSocketHandle == NULL)
pState->m_pmapSocketHandle = new CMapPtrToPtr;
if (pState->m_pmapDeadSockets == NULL)
pState->m_pmapDeadSockets = new CMapPtrToPtr;
if (pState->m_plistSocketNotifications == NULL)
pState->m_plistSocketNotifications = new CPtrList;
#endif
}
[insert witty comment here]
bdiamond
|
|
|
|
|
Thanks, this looks very helpful.
Any idea whether I call this before /after /instead of AfxSocketInit()?
Also, is it OK to declare a CSocket (derivative) as a member and then call it's Create() after running this, or should I just create it on the heap?
Thanks
|
|
|
|
|
In my app, it's called after AfxSocketInit(). I don't think it matters how you declare your CSocket object, as long as you call it before each Create in your new thread. In my app I allocate a CSocket object on the stack because it's only useful for the duration of the function.
[insert witty comment here]
bdiamond
|
|
|
|
|
I cant even get the fuction to run, it barfs at
#ifndef _AFXDLL
So I am at a real loss here. I tried removing this from my preprocessor defs and then I was in real trouble!
Are you actually creating /using your socket from the WinThread? or are you creating a CWnd for it?
Any chnace you can post some code up?
thanks,
|
|
|
|
|
Can any body help me in project in which I want to write data to cd in MFC
|
|
|
|
|
If it is required under XP only, you may check ASPI interface. Otherwise quickest solution will be using 3rd party libraries, like that of binarymagics.com
Igor Green
http://www.grigsoft.com[^]
Compare It! + Synchronize It! : Files and folders comparison never was easier!
|
|
|
|
|
Thanks other then VC++ which other plateform may be best
|
|
|
|
|
I don't know - I'm VC developer myself. But it should not matter - any Win32 development platform will have same limitation - well, maybe you will find free Delphi library for this. Another choice could be .Net - but it will limit your target platform anyway.
Igor Green
http://www.grigsoft.com[^]
Compare It! + Synchronize It! : Files and folders comparison never was easier!
|
|
|
|
|
Maybe. I have written to CDs, and my programs work under windows 2000.
If you can limit yourself to windows XP, there is a cd burning interface that will be easy to use. Check out the limits of that, it might meet your needs.
You can get third party libraries to do the hard work. A little costly, but it might be worth it.
The hardest is what I did: write pure scsi commands to the device, handeling everything manually.
I've been meaning to write a CP artical about what I did (no code as my boss won't approve it, but I can give a lot of hints on what your design needs to account for). Let me know if this would be useful, I've been trying to find some motivation.
|
|
|
|
|
Hi,
I am loading one BMP image from Resource file using CBitmaps::LoadBitmap() function. actually it is 24 bit image but if I use GetBitmap function of CBitmap to see the properties of the Bitmap the it shows the number of bits per pixel column as 32 bits. how come it is.
I want to convert this 32 bit image to 24 bit image. please let me know the how can i do that
Thanks in Advance
|
|
|
|
|
Hello,
The reason that the bitmap is 32 bpp instread of 24 is because of memory alignment.
Pentium processors work faster when data is aligned at 4 bytes (32 bits). Data that isn't aligned at multiple of 32 bits will wreck havoc on the Pentium processor.
The other reason for this alignment is that the most graphics cards don't support true 24 bit color modes. The reason for this is the same as for the Pentium.
Also there are no api's that can copy 3 bytes of memory at once. So for optimizing purposes the momory is aligned at 32 bits.
So you don't need to worry about the 32 bpp since the extra 8 bits are for your own good...
Hope this information was of any help.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
same question i will ask, and the answer of you Mr is not enough, i want to convert from 32bits bimap to 24bits because i am using an engine supports only 24bits bitmap, the conversation is at C# level,
any information is more than welcomed.
|
|
|
|
|
Hi,
Interesting that you found my reply of more than 6 years ago . I can't help you here. Try posting your question in the C# section. Also try to elaborate on the ways that you've explored so far.
Kind regards,
Bob Stanneveld
|
|
|
|
|
Hello,
I want to give SSH based tunneling in my app. My app will then connect to the local port for secure communication over network.
For this I am using PLINK.exe provided at http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Now I want to connect to my server only if PLINK is successful in making a connection to the SSH server.
To do this I am using the following code:
[CODE]
char plinkapp[] = "g:\\myapp\\debug\\plink.exe -ssh -l username -pw pwd -L 1234:127.0.0.1:1235 127.0.0.1";
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset ( &si, 0, sizeof(si) );
memset ( &pi, 0, sizeof(pi) );
si.cb = sizeof( si );
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
bool pret = CreateProcess ( NULL, plinkapp, NULL, NULL, NULL, NULL, NULL, NULL, &si, &pi );
assert ( pret );
WaitForSingleObject ( pi.hProcess, INFINITE );
/* my server code starts from here */
[/CODE]
Now the problem is that if PLINK is successful in connecting to the SSH server then it spawns up a new shell and waits there for input. So if the connection is successful the code segment is never coming out from WaitForSingleObject() code.
Now I want to execute my code only if the connection is successful otherwise return with an error? How do I find out if PLINK was successfull coz it just opens up a shell and waits there. I cant use some arbitrary millisecond to wait in WaitForSingleObject because if the network is slow then it will take more time to connect to the SSH server.
I was just hoping if there is a more elegant method? I tried piping but then the output after connection depends upon the SSH server which might be Linux or BSD or Windows based. So the output is never same.
The only thing i could figure out is that to modify PLINK source code (its opensource and there are no legal issues )? Do you suggest this method?
Thanks in advance.
Regards,
Karam
|
|
|
|
|
Hi
I created a network application using VC++ and CSockets
But the application fails on windows 2003 what could be wrong. ?
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
I can't give you any specific help, just remember that Win 2003 runs very tight restrictions on almost every IO operations.
But you have to provide more info, it could be that you haven't got access to the MFC library, or that you are denied access to the library by Win 2003.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi
Thank you very much.
I will return after trying out your suggestions.
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hi
class CUdpSocket : public CSocket
CUdpSocket m_CUdpSocket;
///////////////////////
m_CUdpSocket.Create(iport,SOCK_DGRAM,"")
this is what fails in windows 2003. Any Idea would be appreciable.
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
What could possible be wrong when CFtpConnection::GetFile(…) returns 5 (Access is denied). I know the file exists and I’ve got the right URL.
Thanks for tips
_____________________________
...and justice for all
APe
|
|
|
|
|
Hello Everyone,
A question related Form design with C++ in Visual Studio .NET 2003.
Scenario
I've one Form, let's call it MyForm, with various controls on it. There's a Panel on this Form on which the user can draw and edit a polygon. Now, the mouse event methods were becoming quite large, so it seemed like a nice idea to write a custom class (MyPanel) which is a child of "System::Windows::Forms::Panel". In this class I for example redefine the "OnMouseMove", "OnMouseDown" and "OnMouseUp".
Next, I changed one line in the "InitializeComponent" method of MyForm; that is, I changed:
"this->panel1 = new System::Windows::Forms::Panel();"
into
"this->panel1 = new Guillotine::CCanvas(this);"
Results & Problem
Now, the above works fine when I compile and run the application. However, I'm in real trouble when I start using the Form Designer. The Form Designer removes all the code related to the Panel, thus clearly does not accept any adaptations to the "InitializeComponent" method of MyForm.
NOTE: The MyPanel class can not be written as a stand-alone control, and then imported through a dll, since it "talks" to various other controls on MyForm!
Question
I realize that InitializeComponent is *not* to be adapted (according to the text preceding this method). However, the above change seems very natural, and the adaptation of the "InitializeComponent" is marginal. My question is whether I can let the Form Designer know that everything is ok with MyPanel (my self defined Panel class), and that the Designer can accept this child of Panel as a Panel?
Looking forward to possible approaches to tackle this problem (or on explanations why I should definitely *not* do this )!
|
|
|
|
|
if you have solution, can you send me the source code to xiayi@ustc.edu?
please contact:
max_xiayi@hotmail.com
|
|
|
|
|
Hello!
I'm currently building an application which uses a kind of "magnifying lens" to zoom into a displayed DIB. I use the mouse to move this "magnifying lens", but I think the mouse pointer is quite annoying while zooming in, so I want to make it disappear.
Does anyone know a nice and convenient way to switch the mouse pointer on and off?
Thanks a lot in advance!
Matthias
|
|
|
|
|
Yes I know the code for it.
|
|
|
|