Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
Sockets, time handling and keyboard interrupt handling in C
A new example from last week's C course - a simple TCP/IP server that processes one connection at a time, taking a user's input into a "giftbox" and returning the donantion made by the previous person. The scenario is that you may be given wonderful gifts by people - but sometimes they're not wonderful for you
and you would like to swap them!
It's all too easy when writing a new example to include too much into it so that readers are overwhelmed; I've tried in this case to make sockets simple, whilst at the same time providing something that works practically. The code illustrates:
• a server written in C
• some time handling in C
• how we trap ^C (keyboard interrupts) in C via signals
The code could be extended to provide
• cleaner shutdown
• forking to handle multiple parallel connections
• extension to handle longer user input strings / gift descriptions
• error checking
• additional logging
Program source is [here]
- together with sample outputs from running it - on server, with client and the logfile. This is not something that we cover on every C / C++ course as it's specialist interest - but if you come on one of our public C courses
and have an interest, I'll cover it after class f (written 2015-03-27, updated 2015-03-29)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesC211 - C and C based languages - Standard Libraries and other headers 
C and C++ - preprocess, compile, load, run - what each step is for - (2011-04-12) 
Your program - you just provide the filling in the sandwich - (2011-04-08) 
OpenGL / C / C++ - an example to get you started - (2011-01-26) 
Sharing variables between files of code in C - extern - (2010-01-14)
Some other Articles
Sorting in Python 3 - and how it differs from Python 2 sortingFour in a Bed - most popular answersNeighbourhood Plan - travel and transport thoughtsMoving from C to C++ - Structured to Object Oriented - a lesson for engineersSockets, time handling and keyboard interrupt handling in CCatching up on a week all in a single post (?)Rail Conference, NottinghamServer program written in Tcl using socketsReading from a URL, and reading Json, from your Tcl scriptUsing Object Oriented Tcl and the Tk toolkit together - real life example
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page
This is a page archived from The Horse's Mouth at
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.
Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).