Contributed by Dengue on from the ask dept.
I am trying to learn programming in C. My end goal would be to help code things for OpenBSD/Linux/Solaris (Basically POSIX stuff.) What are some resources the OpenBSD community can recommend for a newbie C/unix coder? (I am especially interested in network related stuff) I have currently been practicing under my OpenBSD box. What would be some good source (since we have access to all the OpenBSD source) code to look at that would not be too confusing for a beginner?
(Comments are closed)
By Sean Cody () null@tfh.ca on http://www.bitbucket.ca
As for texts there are a few I have found indespensible (and are easily found in libraries.. at least in the ones at my University).
man pages (they kinda suck if you don't know where to start but once you do they are invaluable)
Pocket Guide to TCP/IP Socket Programming in C by Michael J. Donahoo and Kenneth L. Calvert (also known as "The Pocket Socket Guide in C"
UNIX Network Programming, Volume 1, Second Edition: Networking APIs: Sockets and XTI, by Richard Stevens Prentice Hall, 1998.
Both have source code online if you want it.
Bort are very good books on the topic and have personally read through them.
By r0ach () on
By gnudutch () on
By Richy K () richy@pube.org on mailto:richy@pube.org
but with that, you also have to write & write code again...
it's one thing to be able to understand a golden nugget of code, but to (re)produce a concept/idea is another.
-r.
By Hans Insulander () on
You'll need the "C-book" by Kernighan and Ritchie. I've been a C-programmer for many years and i still use it all the time, so it'll be one of your best investments you'll ever make. Any bookstore with computer books knows which book this is.
Try to get to know some people to talk to - if you don't already have them. Informal relations with experienced people is the most important thing, IMO.
For example, see if there are any clubs in your area. If not, usenet and/or mailinglists may be helpful - but make sure your questions are appropriate before posting.
I think someone else mentioned Stevens' books - they are invaluable and a true goldmine. All the bookstores have them.
When you read code, don't assume that it's written right. It may be very old, use bad style, use obsoleted interfaces, be buggy etc.
Last of all, remember to always have fun! You should never feel that you have to write code.
By Andrew () andrew at suspicious dot organization on mailto:andrew at suspicious dot organization
You will be focusing on getting around syntactical issues from the start. This means that you won't be able to focus as much effort on learning real concepts that apply to computer science.
You will have to worry about garbage collection, making sure your programs don't leak, and bounds checking. These are complex issues, issues that the beginning programmer shouldn't have to worry about until later when he or she has more experience.
You will have to worry about data types, data conversation between types, precision, and all the issues surrounding a strictly typed language. Again, pretty daunting to someone who should be learning general concepts first.
Programming is programming, but I would recommend that you start with a language that keeps syntactical issues to a minimum and lets you explore pure computer science ideas without hassle. One very real possibility is Scheme (http://www.schemers.org/). Its syntax is extremely simple, it has garbage collection, and is academically backed (MIT) as a beginning computer science language. MIT even has their text book online free-of-charge: http://www-mitpress.mit.edu/sicp/
C is a necessity in the software development world. However, trying to jump directly into C is like jumping into the deep end of the pool with little ability to swim yet. Focus on concepts and not implementation issues as a starting programmer, and when you transition to C, you will have much less to worry about.
By Dennis Schwarz () denniss@stickupkids.org on mailto:denniss@stickupkids.org
By Sean Cody () null@tfh.ca on http://www.bitbucket.ca
By Anonymous Coward () on
"The C Programming Language" by Kernighan and Ritchie.
"Practice of Programming" by Kernighan and Pike
"Advanced Programming in the Unix Environment" Richard Stevens.
"Unix Network Programming" by Richard Stevens
These books are good for beginners, but even as an advanced programmer I still find myself referring to them, years later. For supplementary reading, I highly recommend
"Programming Pearls" by Bentley
By gumleef () on
http://bsdroxs.myip.org/books/K_R/kandr.html
a bunch of other
By iie1195 () kschristensen@yahoo.com on http://www.sweetleaf.info
"Practical C Programming" by Steve Oualline (ISBN: 1565923065)
"Linux Socket Programming by Example" by Warren W. Gay (ISBN: 0789722410)
"Pocket Guide to TCP/IP Sockets (C version)" by Michael J. Donahoo, Kenneth L. Calvert (ISBN: 1558606866)
"The C Programming Language" by Brian W. Kernighan, Dennis M. Ritchie (ISBN: 0131103628"
By Jim () on
Bottom line--when reading any book, don't switch off your brain. If something looks wrong to you, it well might be. Take the time to understand what the author is trying to do, and read manpages to see if it's right. None of this stuff is magic.
Jim
By bsdphreak () on
Thx,
bsdphreak
By Ryan Ware () on
There is a dead trees version too from MIT Press.
By Xavier Brouckaert () gav@bugfactory.org on mailto:gav@bugfactory.org
If you want to write AF-Independant applications, take a look at http://www.kame.net/newsletter/19980604/
Rules :
1) Use sockaddr_storage everywhere
2) Use getaddrinfo & getnameinfo everywhere
Unfortunately, I've always got segfaults using getaddrinfo on Linux with glib-2.2.4-19.
I think it's fixed in USAGI, but I haven't tried.
-------
Program received signal SIGSEGV, Segmentation fault.
0x40107558 in getaddrinfo (name=0xbffffd84 "chimay", service=0x0,hints=0x40166660, pai=0x80483d9) at ../sysdeps/posix/getaddrinfo.c:787
Hints appreciated...
By David Sinclair () sinclair@gbg.bonet.se on http://www.gbg.bonet.se/sinclair