Link to home
Start Free TrialLog in
Avatar of yairy
yairy

asked on

communication protocols

I have a general question:

My application needs to connect with a server threw the internet and exchange some information with it.

There are many protocols to do it.
Can one give me a short review
on these protocols, their advantages
and disadvantages.

more then that, could one link me
to some basic source code in C++.

Yair
Avatar of jhance
jhance

Since you are going via the internet there is really only one choice available, TCPIP.

Other protocols which are commonly used (on Windows at least) are NetBEUI and IPX.  Most internet routers don't pass IPX and NetBEUI is non-routable.  This means that it will only work on a local subnet.

Beyond this, you've really provided too little information about what kind of connection you need to make and the type and amount of data you need to pass.
Avatar of yairy

ASKER

Maybe I wasn't too clear...

I want my application to connect with
a server and exchange some information
with it.

known protocols / approaches are
sockets, COM, DCOM, finger.... and many more.

I wouldn't know what to choose.
I whould also like some ref to a source code example.

Thanks...



ASKER CERTIFIED SOLUTION
Avatar of jhance
jhance

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yairy

ASKER

You more or less sumarized MY knowledge...
I realy need a breadther view.
Well unless you provide more details about what you're trying to do, what been said is about all I can offer.

This is like you saying how can I get from New York to Chicago?  

Well, you can drive a car, if you had one.  You could fly if you had the money and were in a hurry.  You could ride a bike if you were not in a hurry and looking to get into shape.   You could take a train....etc.  

But it's all speculation until you say, "I've got an important meeting to attend tomorrow morning and I can't leave until after 6 p.m. tonight.  

That really narrows down the possible solutions, doesn't it?
Avatar of yairy

ASKER

a) I want my utility, after being intalled, try from time to time to see if the internet connection is on at the customers computer.

b) If so, it will connect with a known server and ask it if there is a new version of the product (is a flag True...)

c) If so, it will prompt the user
with a choise to download the new
version.

d) downloading will take place.


Clearer ?
Yes, much clearer.

For what you've suggested, I'd recommend using HTTP.  It's simple, universally supported, and likely to be compatible with existing networks, proxies, firewalls, etc.

If you are running this on Windows, the CHttpConnection class in WININET makes this incredibly easy from a programming point of view.

Here is a sample of code that does almost exactly what you are wanting to do.  It opens a page on the server called update.htm, reads the version available there, if it's up to date, it says so, otherwise it opens a browser window and downloads the new version.  



CInternetSession sess;
      try{
            CHttpConnection *pHttpConnect = sess.GetHttpConnection(_T("www.UPDATESERVER.com"));
            CHttpFile *pFile = pHttpConnect->OpenRequest(CHttpConnection::HTTP_VERB_GET, _T("/update.htm"));
            pFile->SendRequest();
            pFile->QueryInfoStatusCode(dwStatus);
            if(dwStatus == 200){
                  // All is OK

                  while(pFile->ReadString(msg) != NULL){
                        // Find the latest version available
                        if(msg.Find(_T("Version: ")) > 0){
                              start = msg.Find(_T("Version: "));
                              finish = msg.Find(_T("</p>"));
                              updatedVersion = msg.Mid(start + 9, finish - (start+9));
                        }

                        // Find the URL of the latest version
                        if(msg.Find(_T("URL: ")) > 0){
                              start = msg.Find(_T("URL: "));
                              finish = msg.Find(_T("</p>"));
                              updatedURL = msg.Mid(start + 5, finish - (start+5));
                        }
                  }
            }
            pFile->Close();

            // If it's newer, ask to download it...
            if(updatedVersion > currentVersion){
                  if(AfxMessageBox("Your copy of NetSwitcher is out of date...\nAn UPDATE is available, click OK to download...\nor Cancel to download later", MB_OKCANCEL) == IDOK){
                        ::ShellExecute(NULL, "open", (LPCTSTR)updatedURL, NULL, NULL, SW_SHOWNORMAL);
                  }
            }
            else{
                  AfxMessageBox("Your copy of the software is up to date!", MB_OK);
            }

      }
      catch(CInternetException *pEx){
            pEx->ReportError();
            pEx->Delete();
      }
Avatar of yairy

ASKER

I'll give you the points,
but I'll feel free to ask some follow questions...

Yair