CPJNFinger v1.04
Welcome to CPJNFinger, A very simple MFC class to encapsulate the Finger
protocol. Finger for those not familiar with all the internet protocols is the
protocol used to retrieve information about a systems users. The information
returned is a simple string and can be used for any purposes. For example the
USGS (United States Geological Survey) use Finger to allow up to date Earthquake
data to be retrieved.
For detailed information about the Finger, you should read RFC 1288. You can
find numerous Web Servers which carry these documents by doing an Internet search for
"RFC"
and "1288".
The sample app provided with the code implements a very simple GUI Finger
client, a definite improvement over the console version provided by MS on NT.
Features
- Simple and clean C++ interface.
- The interface provided is synchronous which provides an easier programming
model than using asynchronous sockets.
- The code does not rely on the MFC socket classes. These classes have a
number of shortcomings, one of which causes problems when they are used in
NT services.
- The code can be used in a console application without any problems (Again
this is not the case for the MFC socket classes).
- A configurable timeout for the connection can be set through the main
class method.
Copyright
- You are allowed to include the source code in any product (commercial,
shareware, freeware or otherwise) when your product is released in binary
form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you
are only allowed to distribute versions released by the author. This is to
maintain a single distribution point for the source code.
History
V1.0 (11 October 1999)
V1.01 (17 October 1999)
- The value returned from GetLastError is now preserved across calls to
CPJNFingerSocket::Close.
V1.02 (3 November 2003)
- Updated copyright messages
- Simplified the code in CPJNFinger::ReadResponse. Thanks to Clarke Brunt
for reporting this issue.
V1.03 (14 April 2006)
- Updated copyright details.
- Addition of a CPJNFINGER_EXT_CLASS macro which makes the class easier to
use in an extension DLL.
- Renamed the class to CPJNFinger.
- Module has been renamed to PJNFinger
- Now uses the author's CWSocket sockets wrapper class. This now allows
the code to support connecting via Socks4, Socks5 and HTTP proxies.
- Updated documentation to use the same style as my web site.
- Did a spell check of the documentation.
- Fixed a graceful disconnect problem in ReadResponse method.
- Fixed a issue in CPJNFinger::Finger when code is compiled with /Wp64
V1.04 (28 December 2006)
- Updated the code to compile cleanly on VC 2005
- Code now uses newer C++ style casts instead of C style casts.
- Provided a GetLastError method which returns the last error which the
code encountered. This is required because due to C++ destructors, the value
stored in GetLastError can be destroyed in the CPJNFinger methods.
Usage
- To use the class in your code simple include PJNFinger.cpp in your project
and #include PJNFinger.h in which ever of your modules needs to make calls
to the class.
- If you do not already have the Base64.cpp/h and SocMFC.cpp/h modules,
these can be downloaded separately from
www.naughter.com/w3mfc.html.
- To see the class in action, have a look at the code in OnFileConnect in
the module "WinFingerDoc.cpp".
- Your code will need to include MFC either statically or dynamically.
- You will need to have a functioning Winsock stack installed and correctly
initialized prior to calling the Finger method. Depending on your
application, this will involve calling either WSAStartup or AfxSocketInit at
start-up of your application.
- You will also need to have afxpriv.h and winsock.h or afxsock.h in your
precompiled header. The code will work just as well in a GUI or console app.
API Reference
The API consists of the single public member function of the class CPJNFinger
CPJNFinger::Finger
CPJNFinger::Finger
BOOL CPJNFinger::Finger(LPCSTR pszHostName,
LPCSTR pszUser, CString& sReply, BOOL
bVerbose
= FALSE, int nPort = 79);
Return Value
If the function succeeds, the return value is TRUE. If the function
fails, the return value is FALSE. To get extended error information, call
::GetLastError.
Parameters
pszHostName The network address of the Finger server to connect to,
e.g. a machine name such as “finger.somedomain.com”, or a dotted IP
address such as
“192.168.1.2”.
pszUser This is the user who you wish to finger, You can set this to
NULL, if you want the server to return a list of users. It can be form "user"
or "user@hostname".
sReply Upon successful return, this will contain the server response
/ finger result.
bVerbose TRUE if you want to signify a higher level of verbosity in
the user information output. The Finger server is free to ignore this flag.
nPort This is the port number on which to connect. The default value
is 79 which is the default Finger port number.
Remarks
Call this member function to perform the actual "Finger".
Contacting the Author
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
28 December 2006