Click to See Complete Forum and Search --> : Socket programming question


ur_unholyness
March 8th, 2005, 12:55 AM
Hi, please have a look at the attachment, it is a sample from the book Teach Yourself VC++ in 21 days, which is a dialog based application and has both client and server functionality in the same dialog resource. It has a function called SetParent, and a member variable of the type CDialog* as its parameter.

I need to make a similar application, but I wish to incorporate the client and the server independently, and also, as SDI or MDI applications, instead of dialog based. I tried to use similar approach as in this example, and seperated client and server functionalities into two different applications, but I get a huge number of errors.

The following are the changes I made

Instead of the CDialog* varialbe type, I used a CFormview* variable,as it is an SDI application.
I used the SetParent function with this variable as the parameter.

Where am I doing wrong here? I am unable to figure it out. Please help.

Ejaz
March 8th, 2005, 01:21 AM
The code that posted has no problem, its a simple dialog based application, which works fine. You should post the code that is having the problem.

Btw, you can get better answer from Network Programming (http://www.codeguru.com/forum/forumdisplay.php?f=62)

ur_unholyness
March 8th, 2005, 02:37 AM
Thank you Mr. Ejaz, I will post it there again, but it would be a great help if you could help me with two answers :

In the sample I uploaded, since it is a dialog based one, it uses the CDialog* variable in the SetParent function. If I were to use most of the same code as in the sample, but in an MDI based application, what do I substitute this CDialog* variable with?.

I guess the SetParent function is used to attach the WinSock functionalities to a view, so if one of the views in my MDI application needs network functionalities, how do I attach them to it using this CMySocket class.

Ejaz
March 8th, 2005, 02:53 AM
You can set the pointer of whoever owns the socket, replace the pointer of CDialog with the class which has the socket in it.

Andreas Masur
March 8th, 2005, 02:58 AM
[ Moved thread ]