App Icon MetaKit sample code - CatRecv


This application is a simple TCP/IP server based on Winsock.

What it does: When CatRecv is started, is enters a loop waiting for the CatSend client application to connect. Each new connection sets up its own window to displays the contents of a catalog tree sent by CatSend. You can examine the catalog tree and verify that it actually contains what the DisCat sample program previously saved on file.

What it illustrates: CatRecv is pretty neat. Apart from illustrating how to transfer a complex MetaKit data structure over a network connection, it shows off the new tree and list controls now available in Windows 95 with MFC 4.2, and it demonstrates how to design a little TCP/IP network server. The catalog window uses an Explorer-like tree interface to allow you to easily examine a catalog tree structure, and it didn't even take a lot of work to create it in C++. Since this is mainly intended as a demonstration of the use of MetaKit, some more fancy user-interface features, such as sortable file lists and splitter views were not included, although this is probably quite easy to add.

How to use it: As it is, CatRecv only makes sense in combination with CatSend and DisCat. To try it out, you should first create a catalog file with DisCat which you can then pick up with CatSend. Note that like any typical client-server application, the CatRecv server application must be running before using CatSend to open a connection. Whenever a new connection is opened and a catalog object is received, CatRecv will open a new window with the contents of that catalog.

This sample application uses a fixed TCP/IP port for its communication, but you can change the default port number to any value you like in the opening dialog. Just make sure to use the same port number in CatRecv, or you won't be able to connect.

Known problems: None, but since CatRecv uses both the new Windows common controls and Winsock, you can only run this application on Windows 95, and you need to have a correctly installed version of the TCP/IP protocol stack (such as the one that comes with Windows 95 itself).

You do not need an active network connection or any network hardware, since every TCP/IP installation can select local communication by using "localhost" as a host name (i.e. IP address 127.0.0.1). If you obtained this package from Internet via FTP, then you should be all set, since FTP access implies that you have a properly working TCP/IP configuration.

Files in EXAMPLES\CATRECV:

CATRECV.H, CATRECV.CPP - Main MFC application code
CATRECV.MAK, CATRECV.MDP - MSVC 4.2 project makefiles for Win32
CATRECV.RC - Application resources
MYDLG.H, MYDLG.CPP - Opening dialog
RESOURCE.H - Resource symbol definitions
STDAFX.H, STDAFX.CPP - Used for precompiled headers
TREEDLG.H, TREEDLG.CPP - Contains the interesting pieces of this application
RES\*.* - Application resources


||   Roadmap   Class Index   Sample Index   ||   Introduction   Tips and Tricks   ||