|
Hi @ all,´
i have the problem, i´m trying to send a message via UPD to a client but the select method reacts if the message is incoming on the client.
The client is running as a windows service.
With wireshark I can see the incoming message.
The client is waiting on messages following
while(g_bRun)
{
FD_ZERO(&fdSet);
FD_SET(g_pSipSocket->getSocket(), &fdSet);
rv = select(maxfd + 1, &fdSet, NULL, NULL, &timeVal);
AddDBS(1, "fdSet: %d\n", fdSet.fd_count);
if(rv > 0)
{
rv = recvfrom(g_pSipSocket->getSocket(), buf, sizeof(buf), 0, (SOCKADDR*)&sa, &salen);
if(rv != -1)
{
delay(100);
buf[rv] = '\0';
writeLog(buf);
}
}
}
the special clue is, if I´m sending a message to the client directly after starting my service then it works. If I´m waiting then or before ca. 2 - 3 minutes then the problem manner.
Sorry for my bad english
Best regards
Crazy
|
|
|
|
|
Premises:
1) jobject_instance is a reference to the correct object (another non-void method call worked just as expected), Type: jObject
2) j_method_id is the correct id for the called method, Type: jmethodID
3) Method expects one int as argument and is (of course) void
4) Code is compiled to DLL and used by external application
m_jni_env->CallVoidMethod(jobject_instance, j_method_id,(jint)n);
This results in: Runtime Error R6025, pure virtual function call. Any ideas?
Regards
|
|
|
|
|
Can you show the Java code for j_method_id and how you obtain its pointer?
|
|
|
|
|
Hi,
sure:
Getting the method id:
j_method_id = m_jni_env->GetMethodID(m_class_ref, "testMethod", "(I)V");
m_class_ref is the correct jclass reference, contructor call and another method using this reference are working as expected
and the Java code of the method:
public void testMethod(int n){
try {
this.debugOutWriter.write("testMethod called, n = " + Integer.toString(n) );
this.debugOutWriter.write("----------------------");
this.debugOutWriter.newLine();
this.debugOutWriter.flush();
} catch (IOException e) {
}
}
debugOutWriter is a BufferedWriter just used to test the entire jni stuff before actually implement the real functionality.
|
|
|
|
|
I've just compared this with my own JVM test system and all the calls and parameters look fine. I can only surmise that the external app or the DLL are somehow not in sync. If you call the Java function direct, rather than through the dll does that work? Also, are you sure the runtime error is on the call to the java method, rather than to some class method in the DLL?
|
|
|
|
|
Yes, using the class in a plain java application works just fine.
Directly in front and behind the JNI call for the void method are the following debug outputs ...
fprintf(m_debug, "calling java void method\n" );
fflush(m_debug);
m_jni_env->CallVoidMethod(jobject_instance, j_method_id,(jint)n);
fprintf(m_debug, "called java void method\n" );
fflush(m_debug);
... and the last entry in debug text file is "calling java void method".
But while playing with both, C++ and Java code to get closer to the reason of this error, I discovered that removing
this.debugOutWriter.write("testMethod called, n = " + Integer.toString(n) );
this.debugOutWriter.write("----------------------");
from the Java code solves the problem. Funny thing is, the file access does not seem to be the problem because the lines
this.debugOutWriter.newLine();
this.debugOutWriter.flush();
remain as they were and the "CR/LF"-newline is written into the file correctly. But using the write method is causing the error.
Even if this is only a debug output that won't be required in the final version, I'm still curious about it's origin.
File writing operations won't be required for real functionality, but file read operations and the Java2D framework, and I doubt that this is just a special attitude of the BufferedWriter class..
|
|
|
|
|
Well, I'm afraid I cannot figure out what is wrong with any of your code, it all looks fine to me. Sorry, but I'm unable to offer any further suggestions.
|
|
|
|
|
Thanks for your efforts anyway
I think I just figured out the problem:
The application I'm developping the DLL for seems to be multi-threaded and up to now I didn't attach/detach the current thread to the JVM.
Since the job to be done is linear and there's no gui I didn't thought of that (JVM is created in constructor, method calls are in the interface-method).
I have no idea why the void method without the write operations as well as the object returning method that's called earlier worked just fine without attaching the current thread (and this manner is reproducable!), but it's all working now
Once again, thanks for your effort!
|
|
|
|
|
Happy to help, and glad you found the problem.
|
|
|
|
|
Hi
How to convert Release Build to Debug build.I have a WorkSpase with release configuration ( Debug Multithreaded ).I have changed NDBUG to _DBUG , enabled Link incrementally and changed 'Debug info' to Program Database for Edit and Continue.Even then I am not able to Debug the application.Please Help
Thaks in Advance
|
|
|
|
|
Why can't you just debug the debug build itself instead? If you have a peculiar problem occurring only with the release build, then please read this: Debug vs Release[^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Benjamin Bruno wrote: I have changed NDBUG to _DBUG , enabled Link incrementally and changed 'Debug info' to Program Database for Edit and Continue.
Are you making all of these changes manually?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi,
I'm facing a situation that I've never seen before regarding .exe and .dll files.
The app a.exe uses a DLL x.dll. The x.dll (not a COM DLL, but a regular one) can't be found in the computer hard drive.
After executing a.exe, the x.dll is expanded to the temp folder, to a path like this:
C:\DOCUME~1\COMPANY\LOCALS~1\Temp\tmpABT\07333f01-60fa-473c-9581-344d009b639d\x.dll
This DLL and path exists only during a.exe execution.
In the a.exe directory, there's a .CAB with a lot of DLLs, but x.dll is not inside of it.
The problem is that I have x.dll source code and I wanted to change it's version (used by a.exe).
Any tip on where does the DLL come from ?
Thanks for any help!
|
|
|
|
|
Probably the executable has the x.DLL file stored as a resource within itself and is writing to the hard disk before usage?
However, you could use FileMon from SysInternals[^] to see who is creating the file!
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Yes, it has to be something like this.
I found something using process explorer, after choosing some menu item, the .exe loads an .msi file (yes, the .msi file is listed as loaded as the dlls are), and inside this .msi the is the x.dll.
Now I can use an .msi editor to change the dll inside of it.
Thanks Rajesh.
|
|
|
|
|
I want to add a submenu at the end of 'Edit' Menu at run time at the time of dropdown of Edit menu.
What event I have to use for this purpose?
The submenu content may vary time to time, so I want to append it at the time of main Edit menu dropdown.
Thanks
--
"Programming is an art that fights back!"
|
|
|
|
|
Is maybe WM_ENTERMENULOOP[^] what you are looking for?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi All
I have a problem to use syntax of MSSQL.I use this syntax
use databasename
it is not working for me.I check out through this code
SELECT db_name() then result show MASTER.
Can any one give me tips where i wrong to use syntax.
Plz help me
|
|
|
|
|
I think this[^] is a better place for your question, this Message Board is for C/C++/MFC related questions.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
thanks for reply
i know this message board is for C/C++/MFC related questions.My question is also C/C++/MFC related questions because
USE DATABASENAME syntax working fine in MSSQL.When i use this sysntax in MFC/C++ then it's not working.So here i ask this question.
No problem if you think then i have to move from here to there.
Thanks
|
|
|
|
|
I see, in this case, you should probably give some more details of how you tried to achieve your goal and what kind of problem/error did you get. Show some more code, maybe someone will know what is wrong.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
MsmVc wrote: My question is also C/C++/MFC related...
But you've shown no relevant code.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i connect MSSQL 2005 through this code successfuly.
CString str1="",str2="",str3="";
HRESULT hr;
if SUCCEEDED(hr = CoInitialize(NULL))
{
try
{
if (SUCCEEDED(spSQLServer.CreateInstance(__uuidof(SQLServer2))))
{
try
{
HOST=(_bstr_t)m_MHOST;
if(rad1.GetCheck())
{
spSQLServer->LoginSecure = TRUE;
spSQLServer->Connect((_bstr_t)m_MHOST);
}
else
{
spSQLServer->LoginSecure = FALSE;
spSQLServer->Connect((_bstr_t)m_MHOST,(_bstr_t)m_MUSR,(_bstr_t)m_MPWD);
}
}
catch(_com_error pCE)
{
str2.Format(_T("%s"),
MessageBox(str2,"Message");
return TRUE;
}
}
else
{
str3.Format(_T("Unable to create the SQL Server object.\n"));
}
}
catch(_com_error pCE)
{
str2.Format(_T("\n%s Error: %ld\r\n%s\r\n%s\r\n"),
(TCHAR*)pCE.Source(),
pCE.Error(),
(TCHAR*)pCE.Description(),
(TCHAR*)pCE.ErrorMessage());
}
}
else
{
str2.Format(_T("Call to CoInitialize failed.\n"));
}
Then i use this code for use database
QueryResultsPtr Qry;
_SQLServer2Ptr spSQLServer;
CString udata="use databasename";
Qry=spSQLServer->ExecuteWithResults((_bstr_t)udata,(LONG)udata.GetLength());
|
|
|
|
|
fathers and mothers, how to convert hicon to png file?
|
|
|
|
|
nenfa wrote: fathers and mothers
Fathers and Mothers are all on a break now, try Nieces and Nephews.
|
|
|
|