General Information and Concepts




Programming UNIX Sockets in C - Frequently Asked Questions: General Information and Concepts


Previous Next
Table
of Contents


1. General Information and Concepts
1.1 What's new?
Changed on May 21/1998

2.12. Where can a get a library for programming sockets? (fixed a couple
of links)
7. Sample Source Code (put examples on a new ftp server)

1.2 About this FAQ
This FAQ is maintained by Vic Metcalfe ( vic@acm.org), with lots of assistance from Andrew
Gierth ( andrew@erlenstar.demon.co.uk). I
am depending on the true wizards to fill in the details, and correct my (no
doubt) plentiful mistakes. The code examples in this FAQ are written to be easy
to follow and understand. It is up to the reader to make them as efficient as
required. I started this faq because after reading comp.unix.programmer for a
short time, it became evident that a FAQ for sockets was needed.
The FAQ is available at the following locations:


Usenet: (Posted on the 21st of each month)

news.answers, comp.answers, comp.unix.answers, comp.unix.programmer
FTP:

ftp://rtfm.mit.edu/pub/usenet/news.answers/unix-faq/socket
WWW:

http://www.ibrado.com/sock-faq
http://kipper.york.ac.uk/~vic/sock-faq
http://www.ntua.gr/sock-faq

Please email me if you would like to correct
or clarify an answer. I would also like to hear from you if you would like me to
add a question to the list. I may not be able to answer it, but I can add it in
the hopes that someone else will submit an answer. Every hour I seem to be
getting even busier, so if I am slow to respond to your email, please be
patient. If more than a week passes you may want to send me another one as I
often put messages aside for later and then forget about them. I'll have to work
on dealing with my mail better, but until then feel free to pester me a little
bit.
1.3 Who is this FAQ for?
This FAQ is for C programmers in the Unix environment. It is not intended for
WinSock programmers, or for Perl, Java, etc. I have nothing against Windows or
Perl, but I had to limit the scope of the FAQ for the first draft. In the
future, I would really like to provide examples for Perl, Java, and maybe
others. For now though I will concentrate on correctness and completeness for C.

This version of the FAQ will only cover sockets of the AF_INET family, since
this is their most common use. Coverage of other types of sockets may be added
later.
1.4 What are Sockets?
Sockets are just like "worm holes" in science fiction. When things go into
one end, they (should) come out of the other. Different kinds of sockets have
different properties. Sockets are either connection-oriented or connectionless.
Connection-oriented sockets allow for data to flow back and forth as needed,
while connectionless sockets (also known as datagram sockets) allow only one
message at a time to be transmitted, without an open connection. There are also
different socket families. The two most common are AF_INET for
internet connections, and AF_UNIX for unix IPC (interprocess
communication). As stated earlier, this FAQ deals only with AF_INET
sockets.
1.5 How do Sockets Work?
The implementation is left up to the vendor of your particular unix, but from
the point of view of the programmer, connection-oriented sockets work a lot like
files, or pipes. The most noticeable difference, once you have your file
descriptor is that read() or write() calls may
actually read or write fewer bytes than requested. If this happens, then you
will have to make a second call for the rest of the data. There are examples of
this in the source code
that accompanies the faq.
1.6 Where can I get source code for the book
[book title]?
Here is a list of the places I know to get source code for network
programming books. It is very short, so please mail me with any others you know
of.
Title: Unix Network ProgrammingAuthor: W. Richard Stevens ( rstevens@noao.edu)Publisher: Prentice
Hall, Inc.ISBN: 0-13-949876-1URL: http://www.noao.edu/~rstevens
Title: Power Programming with RPCAuthor: John BloomerPublisher:
O'Reilly & Associates, Inc.ISBN: 0-937175-77-3URL: ftp://ftp.uu.net/published/oreilly/nutshell/rpc/rpc.tar.Z
Recommended by: Lokmanm Merican (lokmanm#pop4.jaring.my@199.1.1.88)Title:
UNIX PROGRAM DEVELOPMENT for IBM PC'S Including OSF/MotifAuthor: Thomas
YagerPublisher: Addison Wesley, 1991ISBN: 0-201-57727-5
1.7 Where can I get more information?
I keep a copy of the resources I know of on my socks page on the web. I don't
remember where I got most of these items, but some day I'll check out their
sources, and provide ftp information here. For now, you can get them at http://www.ibrado.com/sock-faq.
There is a good TCP/IP FAQ maintained by George Neville-Neil ( gnn@wrs.com) which can be found at http://www.visi.com/~khayes/tcpipfaq.html

Previous Next
Table
of Contents


Wyszukiwarka

Podobne podstrony:
07a?0 Information and Communication
General Relativity and Cosmology for Undergraduates J Norbury
01 general information
Basic Terms and Concepts
45 1 General information ABS
Jackson on Physical Information and Qualia
C# and C Beginning Visual C# 2010 Book Information and Code Download Wrox
Information and History regarding the Sprinter
Navy Concept Generation and Development
Functional Origins of Religious Concepts Ontological and Strategic Selection in Evolved Minds
On demand access and delivery of business information
Bertalanffy The History and Status of General Systems Theory
180 cm diam wind turbine blades and generator
Eric D Weitz Racial Politics without the Concept of Race Reevaluating Soviet Ethnic and National
MAPS Vol12 No1 How Psychedelics Informed My Sex Life and Sex Work

więcej podobnych podstron