|
Yes, you're right. I made a blunder, forget it.
Could you please show us how a client uses the ToolBox ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Of course. Only the client doesn´t use the ToolBox. The server does. For each client it has to create an RTP Header for an RTP data transfer. Which is done in my class RTPHeader.
RTPHeader::RTPHeader( int payloadType )
{
m_pLogger = Logger::GetInstance();
m_pToolbox = ToolBox::GetInstance();
m_pLogger->Out(Logger::DEBUG, "RTPHeader: Constructing Header.\n");
for( int i = 0; i < 12; i++ )
{
m_aHeader[i] = 0;
}
SetPayloadType( payloadType );
SetVersion( (BYTE) 2 );
GenerateNewSsrc();
m_bFirstGetInc = true;
PrintToConsole();
}
RTPHeader::~RTPHeader(void)
{
}
void RTPHeader::GenerateNewSsrc()
{
m_aHeader[9] = m_pToolbox->GenerateRandomByte();
m_aHeader[10] = m_pToolbox->GenerateRandomByte();
m_aHeader[11] = m_pToolbox->GenerateRandomByte();
}
.
.
.
In GenerateNewSsrc() the ToolBox´s Random Generator is used. It works nicely for this small piece of code. Only that for the next client that connects to the server it will generate the same sequence all over.
And my test output in the ToolBox class actually shows that it is indeed the rand() method that produces the same results. It´s not a variable that wasn´t cleared or such something. A new RTPHeader class object is created for every client.
Cheers
|
|
|
|
|
Is your application multi-threaded? Because the state of the random number generator is held in per-thread storage (i.e. there's a different random number state for each thread). And if each of those states is initialised the same way...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hmm .. good idea. That might be it. Though I don´t thoroughly understand it.
I indeed use multi-threading. Though there is only one object of the number generator and only one call of srand(). So each thread uses the same instance of the generator, which is actually what I intended because if srand() would be called for each worker thread (one per client), it could happen that two clients connect at the same time, get the same srand()-initialization and therewith produce the same sequence of numbers again. Right?
Souldrift
|
|
|
|
|
Souldrift wrote: Though there is only one object of the number generator and only one call of srand(). So each thread uses the same instance of the generator, which is actually what I intended because if srand()
No, no, no - each thread will have its own random number generator state - it's held inside the C run-time library (look at rand.c in the C run-time source). Even though you have one toolbox object, that's immaterial, because your object doesn't hold the random number state.
The call to srand() will only effect the thread on which the toolbox object is constructed. The other threads will get some default random number generator state initialisation.
Your best bet would be to use a different PRNG - for example, one of the implementations included in Boost[^], where (as you have full control over the PRNG including the data it uses) you could ensure that you have a single state for ALL threads. Of course, you'd then need to put a lock on the random number acquisition function (to ensure only one thread calls it at once)...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Okay. That´s good to know .
I´ll look into Boost. And sure thing about the lock ... I would have taken care of that later on, anyway.
Thanks for now
Souldrift
|
|
|
|
|
Hi Guys i am using crstal report 11.5 to print the sevral reports its working fine but suddenly it starts giving "Invalid TLV record" and then if i uninstall the crstal report and install it back it again working fine ..
any clue whats going wrong...i searched on google and find some good info but
http://forums.techarena.in/software-development/1052995.htm[^]
not able to find the root cause ..
any help will be helpful
Thanks
vikas da
|
|
|
|
|
This forum is for discussions related to C/C++/MFC.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
right i am using MFC to print the report..
do we have any place in CP where we can discussing about ...
vikas da
|
|
|
|
|
I want to call the java dll from MFC application.
can we do this?
if yes how to do it?
Actually i have ssh dll in java,
and i want to call it from MFC.
sunny
|
|
|
|
|
|
sunnyram wrote: java dll
What is a 'java dll'?
If you have a DLL, you may call the exported functions.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Thank you for your reply.
sunny
|
|
|
|
|
Hello all,
I am making client server application in which
1)On client side it search required update for PC then make its list and send it to server.
2)On server side it is downloading respective file for updates from its url and storing on server.
till this point I done it.
3) Now I want to install that update on client machine how should I install it, please help me.
Thank You,
ashish p.
|
|
|
|
|
Hi,
How can i capture a Message/notification from a Child control which is again a child of another window. Window->Child->Child1. My question is how can i capture Child1's message in Window?
for me Window is the parent window of the application,
Child is a tab control,
Child1 is aedit control.
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
Get Child to re-send Child1 messages to window?
Put in a WM_NOTIFY handler for Child1 in Child and forward all of those messages to Window. Add a WM_NOTIFY handler for Child in Window. Look at the hwndFrom member of the NMHDR part of the notification message to see which window originally sent the message.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I wrote only messgae loop for parent window, can you tell me how i can incorporate message loop for child windows.
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
A message loop is the same irrespective of whether it is for a parent window or a child window or a window in another thread.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Let me descrip my problem more precisely:
Window->Childwindow(Tab control)->ChildWindow1(edit control).
In windows message loop
{
case WM_NOTIFY:
{
switch(nmhdr->idFrom)
{
case IDC_MAIN_TREEVIEW: //childwindow's Id
switch(nmhdr->code)
{
//I am expeccting notify messages from ChildWindow1?
}
}
}
}
Please let me know weather i am doing correctly.?
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
birajendu wrote: In windows message loop
Do you mean in the message loop or in the WNDPROC for Window (I think it's the second one).
birajendu wrote: //I am expeccting notify messages from ChildWindow1?
No - they get sent to the Tab control - which has a different WNDPROC. You need to subclass it so that you can process the window messages sent to it. See the message I previously posted about subclassing windows.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The message loop will handle all windows created on the thread it's in (a simplification, but close enough).
To modify the behaviour of the child windows, you need to subclass them, to handle messages sent to them differently than the default. I would suggest you read up about window subclassing - this[^] is a good starting point.
For example, to subclass a tab control created in your topmost window, you might use this to create and then subclass the control.
RECT rcCLient;
GetClientRect(hWnd, &rcCLient);
hwndTab = CreateWindow(WC_TABCONTROL, _T("tab"), WS_VISIBLE|WS_CHILDWINDOW, 0, 0, rcCLient.right, rcCLient.bottom, hWnd, 0, hInst, 0);
oldTabProc = (WNDPROC)::SetWindowLongPtr(hwndTab, GWLP_WNDPROC, LONG_PTR(&TabWndProc));
This next code fragment is my definition of a window procedure for the tab control that will forward notifications from an edit control contained inside it to the tab control's parent window. It's a bit evil, 'cause it uses a global for the tab control's old WNDPROC, but it illustrates the point.
WNDPROC oldTabProc;
LRESULT CALLBACK TabWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_COMMAND && HWND(lParam) == hwndEdit)
return ::SendMessage(GetParent(hWnd), message, wParam, lParam);
return oldTabProc(hWnd, message, wParam, lParam);
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks a Lot. This served my purpose....
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
I want to redirect Telnet and Ftp to my program.I have tried using pipe to redirect cmd.exe.All commands can be executed well except Telnet and Ftp commands.
Waiting for help!
|
|
|
|
|
Try to be a little more explicit - what erroneous behaviour are you seeing with Telnet and FTP?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|