CHATSRVR: Demonstrates a Windows Sockets Server

Click to open or copy the CHATSRVR project files.

CHATSRVR, a Windows Sockets Server sample application, is a single-document interface (SDI) application that implements a discussion server for clients of the CHATTER sample.

When you run CHATSRVR, a Discussion dialog box appears that asks for the Channel. The Channel is the number that identifies which discussion you want to support (a single machine could be running multiple discussion servers). Once you provide this information and click OK, the main application window appears.

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:

AfxMessageBox; CArchive::Flush; CArchive::IsStoring; CCmdUI::Enable; CCmdUI::SetText; CControlBar::EnableDocking; CControlBar::GetBarStyle; CControlBar::SetBarStyle; CDialog::DoModal; CDocument::DeleteContents; CDocument::OnNewDocument; CEditView::GetEditCtrl; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CObject::AssertValid; CObject::Dump; CObject::Serialize; CStatusBar::Create; CStatusBar::SetIndicators; CString::GetBuffer; CString::LoadString; CString::ReleaseBuffer; CToolBar::Create; CToolBar::LoadBitmap; CToolBar::SetButtons; CView::GetDocument; CView::OnDraw; CWinApp::AddDocTemplate; CWinApp::Enable3dControls; CWinApp::ExitInstance; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::OnFileNew; CWnd::DoDataExchange; CWnd::GetWindowTextLength; CWnd::OnCreate; SetWindowText; wsprintf