CHATTER: Demonstrates a Windows Sockets Client Application

Click to open or copy the CHATTER project files.

CHATTER is a Windows Sockets Client sample application. It is a single-document interface (SDI) application with a splitter window that lets the user send messages to a discussion server (CHATSRVR), which in turn sends them to multiple other CHATTER users simultaneously.

When you run CHATTER, a Setup dialog box asks for the following:

Once you provide all the information and click OK, the main application window appears. To send a message, type it in the bottom pane. Pressing ENTER will send it. To send a multiline message, use CTRL+ENTER.

It is important to note that CHATTER and CHATSRVR could have been written without using a client/server model by having the CHATTER applications send broadcast datagram packets instead of streaming messages to a server. However, this would produce a program with two serious limitations:

  1. Unlike stream sockets, datagram sockets are not guaranteed to be delivered; therefore, some messages may not reach all the other users in the discussion.

  2. CArchive does not support datagram sockets, so all data translation would have to be handled by the program itself, or the user could only chat with those who are using the same version of CHATTER. By using the stream sockets, users of Windows 95, Windows NT ANSI, and Windows NT Unicode versions can chat with each other without concerns of version compatibility.

This sample demonstrates the following keywords:

AfxGetApp; AfxMessageBox; CArchive::Flush; CArchive::IsStoring; CControlBar::EnableDocking; CControlBar::GetBarStyle; CControlBar::SetBarStyle; CDialog::DoModal; CDocument::DeleteContents; CDocument::GetFirstViewPosition; CDocument::GetNextView; CDocument::OnNewDocument; CEditView::GetEditCtrl; CEditView::SerializeRaw; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::OnCreateClient; CFrameWnd::SetActiveView; CObject::AssertValid; CObject::Dump; CObject::IsKindOf; CObject::Serialize; CRect::Size; CSplitterWnd::CreateView; CSplitterWnd::GetPane; CStatusBar::Create; CStatusBar::SetIndicators; CString::GetBuffer; CString::GetLength; CString::IsEmpty; CString::LoadString; CString::ReleaseBuffer; CToolBar::Create; CToolBar::LoadBitmap; CToolBar::SetButtons; CView::GetDocument; CView::OnDraw; CWinApp::AddDocTemplate; CWinApp::Enable3dControls; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::OnFileNew; CWnd::DestroyWindow; CWnd::DoDataExchange; CWnd::GetClientRect; CWnd::GetWindowText; CWnd::GetWindowTextLength; CWnd::KillTimer; CWnd::OnChar; CWnd::OnCreate; CWnd::OnTimer; CWnd::PreCreateWindow; CWnd::SetTimer; CWnd::SetWindowText; SetWindowText; rand; wsprintf