Server: Chat Server Sample

Click to open or copy the files for the Server sample.

The GlobChat server includes the following source files and functions.

About.c

Displays the About dialog box.

Function Description
CmdAbout Displays the About dialog box
About Processes messages for About dialog box
MsgAboutInit Initializes the About box with version information from resources
MsgAboutCommand Processes WM_COMMAND message sent to the About box
CmdAboutDone Frees the About box and related data

Dispatch.c

Implements the generic message and command dispatchers.

Function Description
DispMessage Calls the function associated with a message
DispCommand Calls the function associated with a command
DispDefault Calls the appropriate default window procedure

Generic.c

Implement the windows procedure for the main application windows.  Also implements the generic message and command dispatchers.

Function Description
WndProc Processes messages for the main window
MsgCreate Handles the WM_CREATE message.  Sets up Display and initializes listening sockets.  Also advertises the service.
MsgSize Resizes the listboxes to fit nicely in main window
MsgTimer Handles the WM_TIMER messages which alerts you to the fact that it's time to send a SAP packet
MsgConnected Handles new connection notifications
MsgDataready Handles recv data notifications and close socket notifications
MsgCommand Handle the WM_COMMAND messages for the main window
MsgDestroy Handles the WM_DESTROY message by calling PostQuitMessage
CmdExit Handles the file exit command by calling destroy window on the main window

Init.c

Performs application and instance specific initialization.

Function Description
InitApplication Initializes window data and registers window

Misc.c

Contains all helper functions "global" to the application.

Function Description
CenterWindow Centers one window over another
AtoH Converts ascii to network order hex
BtoH Converts ascii byte to numeric
deregistername Notifies "Available" peers of clients nonavailability
senddatamessage Sends a message to a client node
recvdatamessage Reads an entire message
UpdateClientList Updates Client Status listbox
MakeServSock Attempts to initialize socket for listening

Winmain.c

Calls initialization functions and processes the message loop.

Function Description
WinMain Calls initialization functions, processes message loop

Building SDK Samples

This sample uses the following keywords:

accept; atoh; bind; btoh; centerwindow; closesocket; cmdabout; cmdaboutdone; cmdexit; createfont; createwindow; defdlgproc; defframeproc; defmdichildproc; defwindowproc; deleteobject; deregistername; destroywindow; dialogbox; dispatchmessage; dispcommand; dispdefault; dispmessage; enddialog; enumprotocols; get_wm_command_cmd; get_wm_command_hwnd; get_wm_command_id; getaddressbyname; getdc; getdevicecaps; getdlgitemtext; getfileversioninfo; getfileversioninfosize; getmessage; getmodulefilename; getsockname; getstringres; getwindow; getwindowlong; getwindowrect; globalalloc; globalfree; globallock; globalunlock; heapalloc; heapcreate; initapplication; listen; loadaccelerators; loadcursor; loadstring; lstrcmp; lstrcpy; lstrlen; makeservsock; makeword; memcpy; movewindow; msgaboutcommand; msgaboutinit; msgcommand; msgconnected; msgcreate; msgdataready; msgdestroy; msgsize; msgtimer; muldiv; pfncmd; pfnmsg; postquitmessage; reallen; recv; recvdatamessage; registerclass; releasedc; send; senddatamessage; senddlgitemmessage; sendmessage; sendto; set_netbios_sockaddr; setdlgitemtext; setsockopt; settimer; setwindowpos; showwindow; socket; strcpy; svcid_netware; svcid_tcp; switch; translateaccelerator; translatemessage; updateclientlist; updatewindow; verqueryvalue; virtualalloc; winmain; wndproc; wsaasyncselect; wsagetlasterror; wsastartup; wsprintf