<< |
Winsock Programmer's FAQ |
>> |
These examples show you how to implement several basic kinds of client and server programs. All the client programs simply connect to an echo server, send a packet of data, read the echoed reply back from the server, check that the data in the reply packet is what was sent, and exit. The server programs implement various forms of the echo server idea. (You can also use a standard "port 7" echo server available as an option on many Unix boxes and Windows NT/2000.) The echo server idea lets us focus more on the structure of the program and less on its function, and yet still provide a fairly functional program. Although these programs are "minimal" in the sense that they don't do much, they are still complete in that they do all the proper error checking, shut their connections down gracefully, are fully commented, etc. Some thought has been given to making it easy to swipe pieces of code from these examples. These programs all follow the same form as much as possible. Any
time you find two functions named the same in two different
examples, you can be sure that they have the same function,
so you can study them comparatively. For example, you can study
Right now, I only have one simple client and one simple server
here, but more are soon to come, as I find the time. The next
program will be a multi-connection multithreaded server, and then
a Support FilesYou should probably download all of these before you begin, because all examples require at least one of these files. Makefile - The Makefile (Borland and Microsoft C++-compatible) that builds the examples. (Not required, but makes building the examples easier.) main.cpp - The ws-util.cpp - A set of Winsock utility functions used by more than one example program. ws-util.h - Header file for ws-util.cpp. The ExamplesThese are the main example files. Each example comes in a single file; the header comment in that file tells you which other modules it requires. Each of these examples illustrates a particular design choice. You can find answers on "which choice is better" for a given application in Tutorial 1. Obviously, no one design choice is best for all situations, or we would not have so many choices. Between the Tutorial's advice and these concrete examples, you should be able to make your decision fairly easily. Basic blocking client - A client that uses blocking sockets. This is the simplest of the programs here. Basic blocking server - A single-connection server that uses blocking sockets. |
<< Example Programs | Basic Blocking Client >> |
Last modified on 29 April 2000 at 15:52 UTC-7 | Please send corrections to tangent@cyberport.com. |
< Go to the main FAQ page |
|
<<< Go to my Home Page |