Solved

communication protocols

Posted on 2000-03-31
8
316 Views
Last Modified: 2010-04-02
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
0
Comment
Question by:yairy
  • 4
  • 4
8 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 2673420
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.
0
 
LVL 2

Author Comment

by:yairy
ID: 2676883
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...



0
 
LVL 32

Accepted Solution

by:
jhance earned 300 total points
ID: 2677389
You're _STILL_ being unclear and you are lumping several things together as "protocols" which are not:

sockets - a programming interface used to write a program to communicate via TCPIP

COM - an binary object specification

DCOM - COM extended to support multiple computers.

finger - a service which is most commonly found on unix boxes which provides information about users.

Again, you said you needed to connect via the internet.  That implies TCPIP protocol.  There are no other choices.  

To accomplish that connection, you will need to use the sockets programming library.  Again, there are no other choices since you must use TCPIP.

Once you have a connection via a socket, the format of the actual data exchanged (what you are calling protocol perhaps) is entirely up to you since you are implementing both the client and the server.

It's only when you need to connect to or receive connections from an established service or client that you need to adhere to a particular data "protocol".  Examples of this would be POP-3, SMTP, and HTTP.
0
 
LVL 2

Author Comment

by:yairy
ID: 2682237
You more or less sumarized MY knowledge...
I realy need a breadther view.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Expert Comment

by:jhance
ID: 2682357
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?
0
 
LVL 2

Author Comment

by:yairy
ID: 2682402
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 ?
0
 
LVL 32

Expert Comment

by:jhance
ID: 2683207
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();
      }
0
 
LVL 2

Author Comment

by:yairy
ID: 2695842
I'll give you the points,
but I'll feel free to ask some follow questions...

Yair
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 66
std::atomic with custom class 6 190
Cross compile release version of c++ program for linux 2 131
Move constructor only called if marked noexcept? 6 98
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now