Skip to main content

Posts

Showing posts from October, 2011

brief description about linux socket programming

steps for client socket connection 1. create a client socket 2. connect with server 3 read and wirte data steps for socket server connection 1.create a sockets system call 2.bind the socket to an address using the bind() 3.listen for connection with the listen system call 4.Accept the system call with Accept() 5.send and receive call using read and write two socket can connect if there address domain and the socket type  are same and should b same domain. there are two most used address domains one is unix domain and another is internet domain in which two processes runinf on any two hosts on the internet communicate.each of these has its own address format. in unix Domain address of a socket in character string format which is basically an entry in the file system. the address of a socket in internet domain consist of the internet address of the host machine (every computer on the internet has a unique 32 bit address ,often refered to a its IP address) In addit...

What is Document/View Architecture in MFC?

By default MFC application wizard creats with an skeleton with a document class and another is view class.MFC seperates data management into these two class.The document class store the data and print the data and view display the data and manages the user interaction with it. Notepad is simple example for SDI application. or ALL MFC application which have user interface follow this architecture. Any MFC application creates with two basic skeleton one is document class and another is view class.document manages the data for multiple view,and view class displays the data. MFC document/view architecture makes it easy to support multiple view,multiple document types, splitter windows and other valuable user interface features. . For exm:- in SDI application we have following major class:- 1. CMainFrameApp:- Frame class derived  from the CFrameWnd 2. CMySDIView :- View class derived  from the CView class 3. CMainDoc :- Document class derived  from the CDoc...

Difference between DLL and EXE

EXE An exe always runs in its own address space, It is a separate process. The purpose of an EXE is to launch a separate application of its own. DLL A dll always needs a host exe to run. i.e., it can never run in its own address space. The purpose of a DLL is to have a collection of methods/classes which can be re-used from some other application. DLL is Microsoft's implementation of a shared library.

What is Message Map in MFC?

MFC provides a techniq for   Windows program to handle Message send to  window.A mapping from message to member functions may be defined so that one message is handled by windows ,a appropriate member function called automatically.A MFC class which handle a Message Map should be member of CCmdTarget class . Message Map is MACRO.in which we define the member function which interact with the windows.Like mouse event etc are define in Message map MACRO.

What is MFC& and CObject

MFC stands for microsoft foundation class ,Its a microsoft class library ,its a wrapper of the API ,its use for creating Windows application( GUI application) in Windows .basiccally in MFC there is two class CFrameWnd and CWinApp CframeWnd is provide the funcitonalities related to  GUI and CWinapp for application level functionalities .. Both these classes derived from CCmdTarget .CCmdTarget is created with the capability to handle windows messages,which is referred as Message Maps.CCmdTarget is derived from CObject CObject:-               its main root class for major MFC class.it provides these major features in your own class Object  like as Serialization support,run time class information and object  diagnostic output.   CObject  class has the ability to determine the exact class of an object at run time. Some classes are not derived form the CObject like CString ,CTime,CTimespan  CObject Serialization sup...

Thread synchronization part 2 (CEVent)

CEvent:- When a synchronization object that allow one thread to notify another that event has occurred now another thread can perform task.one thread is reading a doc and another is writing the thread .that time first writing thread write the file and when its task has done then its single to other thread now reading thread can read the thread. CEvent object is two types :- 1. Manul :-Manual CEvent object stays in the state set by SetEvent or ResetEvent untill the other function is called 2. Automatic:- in an automatic CEvent object automatically returns to a nonsignaled state after at least one thread is released. CreateEvent function's argument decide it  is a maual or auto event and it declare the event a name or unnamed event object,SetEvent function is used to put thread in signal state and ResetEvent function is used to put thread in non signal state.OpenEvent function is used to open a already created event by createEvent () function. HANDLE WINAPI CreateEvent...

Thread Synchronization part one

There is two kinds of Synchronization:- 1.Synchronization in same process     eq.Critical section 2.Synchronizaiton in different process    eq. CEvent,Mutex,SemaPhore 1.Critical Section:-      It is same as a Mutex,but difference between them is Mutex can Synchronization different process where as Critical Section work in to the same process..Critical section is fastest Synchronization object compare of the other ,because it work in same process. CRITICAL_SECTTION m_cs; InitializeCriticalSection(&m_cs); void threadfirst() { EnterCriticalSection(&m_cs); ........ ......... LeaveCriticalSection(&m_cs); } void threadSec() { EnterCriticalSection(&m_cs); ....... ....... LeaveCriticalSection(&m_cs); } Critical Section Example:- #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <process.h> #include <windows.h> #include <iostream> using namespace st...

create a piramid in c++

#include <stdio.h> #include <stdlib.h> #include "stdafx.h" #include <iostream> using namespace std; int main() { for(int i=1;i<5;i++) { for(int j=0;j<5-i;j++) { printf(" ") ; } for(int k=0;k<(2*i-1);k++) { printf("*"); } printf("\n"); } for( i=5;i>0;i--) { for(int j=0;j<5-i;j++) { printf(" ") ; } for(int k=0;k<(2*i-1);k++) { printf("*"); } printf("\n"); }  return 0;   }          *        ***      *****     ******      *****        ***           *

operator overloading

what is operator overloading? operator overloading like a function overloading ,a Programmer can overload the operator .A programmer can create his or her own operator in a class  using by overloading the built in operator to perform some specific computation when the operator is used on the object of that class. some operator we can not overload like scope resolution operator (::),member selection(.) and pointer member selection (.*). #include <stdio.h> #include <stdlib.h> #include "stdafx.h" #include <iostream> using namespace std; class Complex {     int img,real;     public:     Complex(){img=0;real=0;}     Complex(int r,int i){img=i;real=r;}    Complex operator+(Complex  );    void show(){cout<<real<<"+  i"<<img<<endl;} }; Complex Complex::operator+(Complex com) {     Complex value;     value.real=real+com.real;   ...