where should i start to learn how to write a server in C? [duplicate]
Possible Duplicate:
开发者_如何学Pythonsimple client and server
I want to learn how to code a server in C, preferentially using threads, but i don't know where to start. I just want to learn the real basics to improve it gradually, so i think i want to code something simple first, like an echo server. can anyone help me?
If you are interested in Network Programming then Beej's Guide to Network Programming might be of interest.
I suggest getting the Stevens TCP/IP Illustrated series. There is example code which walks you through that sort of thing. Yes, it goes into a great deal of detail not 100% necessary to just write a simple TCP server, but it very good none-the-less.
You might also want to take a peek at the ttcp.c source code. It hooks standard in to the network to standard out. eg:
host b> ttcp -r | tar xf -
host a> tar cf - . | ttcp -t b
Though simply running:
host b> ttcp -r
host a> ttcp -t b
Should show you the concepts.
I can also suggest, using a third-party library like Apache Runtime Library, mostly used by the famus webserver. It's better if you want to write portable applications. Here is the latest documentation.
精彩评论