|
Manmohan29 wrote: can I get your email ID so that I can ask for programming help.
Sorry but
1. I like to decide which questions I answer
2. You will get better and faster help through the forums
3. You could not afford my fees
good luck!
|
|
|
|
|
Thanks Richard.
Can I get your bank ID so that I can ask for financial help?
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]
|
|
|
|
|
I cannot believe that is happening with this code.
You should put a breakpoint at the line with InsertItem and check the value of c .
By the way, you need to get rid of the first 2 for statements.
|
|
|
|
|
Richard MacCutchan solved my problem.
The ListCtrl was sorting the items in ascending order. I have set the Sort field to None.
Now the program just runs fine.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
By the way, you need to get rid of the first 2 for statements.
My program(ping application) is just at initial stage.
The for loop initializations will be replaced when the values will be taken from the user itself.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Question :
The “Dating Game” is an IPC problem which illustrates the sorts of problems that processes
might face if they must try to blindly locate one another. The model uses two sets of processes: males
and females, and the objective is to arrange couples of one male and one female each.
It is guaranteed that:
• each process knows their own sex;
• each process knows their own process ID;
• each process cannot tell the sex of a process simply by examining its process ID; and
• there may be an arbitrary number of males and females in the system at any given moment.
A process has found a mate if they know (by say, storing it in their memory space) the process ID of
a process of the opposite sex, but also if the same condition holds for the opposing process as well.
In other words, m is the mate of f when f knows m and m knows f. At this point, they can start
chatting, sending love letters, buying each other gifts and doing all the things that couples tend to do.
All of this cannot come about without the special intervention of the dating server. The purpose of the
dating server is to find mates for the many fish in the sea. The dating server [process] is well known
by all of the processes in the system, and so consider its process ID to be a universal system constant.
Your primary job in this question will be to solve the dating game using the family of message-passing
IPC primitives: nonblocking send and blocking receive.
(a) Using the messaging system calls, you will simulate the interaction described above.
They are:
• msgget(...) which either: creates a message queue in the case of the dating server; or
identifies a queue, in the case of a male process or a female process.
• msgrcv(...), which will be used as a blocking call for this implementation. All messages will
have a nonzero message type: the unique number associated with each receiver. Messages to
be sent to the dating server will be of type 1; messages to be sent to a process with process
ID n will be of type n.
• msgsnd(...), which will be used as a nonblocking call for this implementation. All messages
sent will have a nonzero message type.
• msgctl(...), which will be used to dismantle the queue.
Your job will be to write the programs for dserver.c, male.c, and female.c, using the message-
passing primitives described above. Mated couples should pass some messages back and forth
before exiting.
Messages are sent to and received from a single queue whose key is the last 5 digits of your student
number. Be sure to update global.h before you begin!
The program dispatcher.c will create males and females at some arbitrary times. You may
modify dispatcher.c, within reason. When testing your code, we will replace dispatcher.c with
our own custom-built version that creates males and females according to our favorite distribution.
In all other aspects, dispatcher.c will be the same as the sample.
(b) [10 marks] Draw a process diagram that illustrates the interaction between the dating server, male
processes, female processes, and the dispatcher. Show any process creation, send or receive.
(c) [5 marks] An analog to the dating server exists in most systems. It is called a nameserver. Explain
what might happen in a client-server system in which there was no nameserver.
(d) [15 marks] It is possible to solve the dating game problem without messages and a dating server.
Instead, we used a shared memory space, some semaphores and two global variables. Write some
pseudocode for functions male() and female() that accomplishes this.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Dear Friends
I have to answer all these a,b,c,d answers can you tell how can I develop sucha IPC application.
Some hints: If anybody has come across such IPC development can you give me some hints to develop an IPC program in VC++ in C language !
Any help would be appreciated
Thanks
|
|
|
|
|
My hint: read the documentation [^].
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]
|
|
|
|
|
Hi All,
I am having a requirement to set a different Color for Different Colmn for a CListCtrl. For Example.
//Insert the Columns
ptr->InsertColumn(0,L"Name",LVCFMT_LEFT,100);
ptr->InsertColumn(1,L"Age",LVCFMT_LEFT,100);
ptr->InsertColumn(2,L"Address",LVCFMT_LEFT,100);
The First Colum must be Entire Blue,
Second Column must be Red,
Thrid Column must be Green.
How can we achieve this.
please help me out.
Uday.
|
|
|
|
|
|
I want to add a splitter bar to divide the dockable pane window into 2 parts. Any idea on how to achieve this?
Actually somewhat similar to VS2008 style class view.
|
|
|
|
|
With the help of "Superman", I was able to prevent all but one memory leak generated by the 'new' operator:
{164} client block at 0x00187CA0, subtype c0, 28 bytes long. a CObject object at $00187CA0, 28 bytes long
Questions: 1. I understand most of what the Visual Studio 2008 teaches. Am I doing something incorrectly
to generate this leak?
2. Do I have to do something with this, or will the memory be released upon exiting Visual Studio.
There are several 'normal block' memory leaks also indicated. They take the form of:
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {166} normal block at 0x00187D68, 28 bytes long.
Data: <, e > 2C FB 16 65 05 00 00 00 05 00 00 00 01 00 00 00
Questions: 1. This appears to be generated inside an executable supplied by Visual Studio. Is this a Microsoft "bug"?
If so, what am I doing to cause this and others of similar form?
2. Same question as #2 above.
3. FWIW, my System Disk Management dialog shows "f:\" as one of my DVD reader/writers. Does Visual Studion
"count noses" differently than Vista 64 does?
Thanks again,
Barry
|
|
|
|
|
BarryPearlman wrote: {164} client block at 0x00187CA0, subtype c0, 28 bytes long. a CObject object at $00187CA0, 28 bytes long
You could add the following to the beginning of your source files (after inclusion of all header files) so that the debugger will be able to pinpoint the memory which is leaking (line number and source file name).
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
Of course you should build in debug mode in order for this to work.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Worked like a charm; all leaks stopped to date. I haven't touched C++ & MFC in years and I forgot the basic rule of "when you are done with your crayons, put them away!"
Thanks for your reply.
Barry
|
|
|
|
|
BarryPearlman wrote: Worked like a charm; all leaks stopped to date. I haven't touched C++ & MFC in years and I forgot the basic rule of "when you are done with your crayons, put them away!"
Thanks for your reply
I'm glad to be of help. It would be great if you could mark the helpful answers (by clicking "Good Answer") and close your thread.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
BarryPearlman wrote: Am I doing something incorrectly to generate this leak?
Probably.
BarryPearlman wrote: will the memory be released upon exiting Visual Studio
Yes, but if the object holds system resources they may not (won't) be cleaned up properly.
BarryPearlman wrote: Is this a Microsoft "bug"?
No, that's just where the actual alloc was called, but higher in the call stack you asked it to do something that resulted in the alloc.
Chances are you have either allocated (or done something that resulted in an alloc) that you haven't cleaned up, or you have a global object that is being constructed after you set the 1st crt mem checkpoint, but being destroyed after the 2nd crt mem checkpoint e.g. a function level static object.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi,
I want to ask something about socket programming in XP. I am using multiple send() and recv() command in a single function in server and client both but its not wroking properly.Actually i am sending a string and it should recv by server and then send back to client in a single function. Simply-
client :
{
printf("\nEnter the string.");
gets(sent_to_client);
send(sock,sent_to_client,sizeof(sent_to_client),0);//it will be sent to server
Sleep(1000);
printf("String is %s\n",sent_to_client);
Sleep(500);
recv(sock,output_from_client,sizeof(output_from_client),0);//here it is received from server
Sleep(1000);
printf("\nreceived sucessfully:\n");
}
server:
{
recv(theclient,input_from_client,sizeof(input_from_client),0);//here it is received from client
here it will be executed on server and the output should be sent to client
send(theclient_to_client,output,sizeof(output_to_client),0);//send to client
}
I was thinking that firstly i will give input string in client then it will be sent to server.In server it will be executed(it can be anything which i want) and then send back to client.In client it will be received sucessfully.But somewhere i am wrong. I don't know where?Please help me.
|
|
|
|
|
ravi 12 wrote: but its not wroking properly.
Could you explain what is not working?
Assuming that you are getting no response from the server you would probably need to repeat the recv() call until some data is returned.
|
|
|
|
|
Hi Richard MacCutchan,
Actually this code is inside on a long code.Only in that section there is no response from server.
client :
{
printf("\nEnter the string.");
gets(sent_to_client);
send(sock,sent_to_client,sizeof(sent_to_client),0);//it will be sent to server
Sleep(1000);
printf("String is %s\n",sent_to_client);
Sleep(500);
recv(sock,output_from_client,sizeof(output_from_client),0);//here it is received from server
Sleep(1000);
printf("\nreceived sucessfully:\n");
}
the output in client window is:Enter the string...
String is:
received sucessfully:
I think that is it the right way to call these functions in single function means should i use this type if(sent()== SOCKET_ERROR) or it is not necessary?
|
|
|
|
|
ravi 12 wrote: I think that is it the right way to call these functions in single function means should i use this type if(sent()== SOCKET_ERROR) or it is not necessary?
Yes, it is very necessary; you must always check the status of every command that can succeed or fail.
From your ouptut information it looks like you have not entered any text to send. Also in your code you print the message "received sucessfully:", but you do not know that you have received anything. Maybe you should spend time studying some of the socket samples on MSDN or Code Project - Google search should find them.
|
|
|
|
|
Hi Richard MacCutchan ,
Thanks for suggestion.For input i am using gets() but it is not taking any string.When Enter the string comes i tries to type string but suddenly it will shows me String is: .and nothing happans.
|
|
|
|
|
ravi 12 wrote: When Enter the string comes i tries to type string but suddenly it will shows me String is: .and nothing happans.
I cannot see what is wrong with your code on this, gets() should wait until you have entered some information before the program can proceed. Perhaps there is something else in your code that is not shown in your original message. Can you post the complete code that is failing (if it's not too long), and please remember to surround it with <pre></pre> tags to keep it formatted.
|
|
|
|
|
I think you should cut off the sleep() function
|
|
|
|
|
send/recv need the length of data, your are sending the size of the char pointer.
So, one way would be for your client to first send the length of the string it is going to send, then send the string.
The server would recv the length, alloc a buffer large enough to hold the incoming string, then recv the string.
... then reverse to send back to client.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
cmk wrote: your are sending the size of the char pointer.
It was not shown how sent_to_client was declared, so why assume it is a pointer?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
You're right, sent_to_client, output_from_client, input_from_client, and output_to_client could all be char[] in the same scope as the send/recv calls that use them.
However, if it they were char[] then i would expect the code to work (assuming no buffer overflow from gets, ...), whereas char* wouldn't.
In lieu of more information it seems like a logical assumption.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|