Windows Sockets example list

Source: Internet
Author: User

The following MFC example program illustrates the functions of Windows Sockets:

  • CHATTER

CHATTER is a Windows Socket Client sample application. It is a single document interface (SDI) application with a split window that allows users to send messages to the discussion server (CHATSRVR ), the discussion server then sends the message to multiple other CHATTER users at the same time.

By sending the CHATTER application to the server a broadcast data packet instead of a message stream, you can write CHATTER and CHATSRVR without using the client/server model. However, unlike streaming sockets, the data message socket cannot be guaranteed to be transmitted. Therefore, some messages may not reach all other users in the discussion. Generate and run an example

Generate and run a CHATTER example

  1. Open solution chatter. sln.
  2. Click Generate on the generate menu ".
  3. Click Start execution (not debugging) on the Debug menu )".

When running CHATTER, you need to enter the following content in the "Setup" dialog box:

Handle
The name used to address all messages. For example, you can select ". The name" ".
Server
The IP address of the computer that runs the CHATSVR example.
Channel
Identifies the number of discussions to be added (one computer can run multiple discussion servers ).

After all the information is provided and click "OK", the main application window appears. To send a message, type a message in the lower pane. Press ENTER to send a message. To send multi-line messages, press CTRL + ENTER. Keywords

This example illustrates the following keywords:

AfxGetApp, AfxMessageBox, CArchive: Flush, CArchive: IsStoring, CControlBar: EnableDocking, CControlBar: GetBarStyle, CControlBar: SetBarStyle, CDialog: DoModal, CDocument :: parameters, CDocument: Alert, CDocument: GetNextView, CDocument: OnNewDocument, CEditView: GetEditCtrl, CEditView: SerializeRaw, CFrameWnd: DockControlBar, CFrameWnd: Alert, CFrameWnd :: onCreateClient, CFrameWnd: SetActiveView, CObject: AssertValid, CObject: Dump, CObject: IsKindOf, CObject: Serialize, CRect: Size, metadata: CreateView, role :: 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: InitInstance, CWinApp: example, CWinApp :: onFileNew, CWnd: DestroyWindow, CWnd: DoDataExchange, CWnd: GetClientRect, CWnd: GetWindowText, CWnd: Counter, CWnd: KillTimer, CWnd: OnChar, CWnd :: onCreate, CWnd: OnTimer, CWnd: PreCreateWindow, CWnd: SetTimer, CWnd: SetWindowText, SetWindowText, rand, wsprintf

Note:Some examples (such examples) have not been modified to reflect changes in the Visual C ++ wizard, library, and compiler, but still demonstrate how to complete the required tasks.
See

MFC example

  • CHATSRVR

CHATSRVR is a Windows Socket Server Sample application. It is a single-Document Interface (SDI) application that is used to discuss the server for the client implementation of the CHATTER sample.

By sending the CHATTER application to the server a broadcast data packet instead of a message stream, you can write CHATTER and CHATSRVR without using the client/server model. However, unlike streaming sockets, the data message socket cannot be guaranteed to be transmitted. Therefore, some messages may not reach all other users in the discussion. Generate and run an example

Generate and run the CHATSRVR example

  1. Open the chatsrvr. sln solution.
  2. Click Generate on the generate menu ".
  3. Click Start execution (not debugging) on the Debug menu )".

When running CHATSRVR, a "Discussion" dialog box for entering "Channel" is displayed. "Channel" indicates the number of discussions to be supported (one computer can run multiple discussion servers ). After you provide this information and click "OK", the main application window appears. Keywords

This example illustrates the following keywords:

Examples, CArchive: Flush, CArchive: IsStoring, CCmdUI: Enable, CCmdUI: SetText, CControlBar: enabled, CControlBar: GetBarStyle, CControlBar: SetBarStyle, cdibarstyle :: doModal, CDocument: DeleteContents, CDocument: OnNewDocument, CEditView: GetEditCtrl, CFrameWnd: DockControlBar, CFrameWnd: lower, CObject: lower, 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: ExitInstance, CWinApp: InitInstance, CWinApp: Signature, CWinApp: OnFileNew, CWnd :: doDataExchange, CWnd: GetWindowTextLength, CWnd: OnCreate, SetWindowText, wsprintf

Note:Some examples (such examples) have not been modified to reflect changes in the Visual C ++ wizard, library, and compiler, but still demonstrate how to complete the required tasks.
See

MFC example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.