• Embed Doc
  • Readcast
  • Collections
  • 21
    CommentGo Back
Download
 
Beej's Guide to Network Programming
Using Internet Sockets 
Brian “Beej Jorgensen” Hallbeej@beej.us
Version 2.4.5August 5, 2007
Copyright © 2007 Brian “Beej Jorgensen” Hall
 
ii
Contents
1. Intro...........................................................................................................................................1
1.1. Audience11.2. Platform and Compiler11.3. Official Homepage11.4. Note for Solaris/SunOS Programmers11.5. Note forWindows Programmers11.6. Email Policy21.7. Mirroring31.8. Note forTranslators31.9. Copyright and Distribution3
2. What is a socket?.....................................................................................................................4
2.1. Two Types of Internet Sockets42.2. Low level Nonsense and Network Theory5
3.
struct
s and Data Handling...................................................................................................7
3.1. Convert the Natives!83.2. IP Addresses and How to Deal With Them8
4. System Calls or Bust..............................................................................................................11
4.1.
socket()
Get the File Descriptor!114.2.
 bind()
What port am I on?114.3.
connect()
Hey, you!134.4.
listen()
Will somebody please call me?144.5.
accept()
Thank you for calling port 3490.144.6.
send()
and
recv()
Talk to me, baby!154.7.
sendto()
and
recvfrom()
Talk to me, DGRAM-style164.8.
close()
and
shutdown()
Get outta my face!174.9.
getpeername()
Who are you?174.10.
gethostname()
Who am I?184.11. DNSYou say whitehouse.gov, I say 63.161.169.13718
5. Client-Server Background.....................................................................................................20
5.1. A Simple Stream Server205.2. A Simple Stream Client225.3. DatagramSockets23
6. Slightly Advanced Techniques..............................................................................................26
6.1. Blocking266.2.
select()
s316.4. Serialization—How toPack Data326.5. Son of Data Encapsulation396.6. Broadcast Packets—Hello, World!41
7. Common Questions................................................................................................................45
 
Contents 
iii
8. Man Pages...............................................................................................................................51
8.1.
accept()
528.2.
 bind()
548.3.
connect()
558.4.
close()
568.5.
gethostname()
578.6.
gethostbyname()
,
gethostbyaddr()
588.7.
getpeername()
608.8.
errno
618.9.
fcntl()
628.10.
htons()
,
htonl()
,
ntohs()
,
ntohl()
638.11.
inet_ntoa()
,
inet_aton()
658.12.
listen()
668.13.
 perror()
,
strerror()
678.14.
 poll()
688.15.
recv()
,
recvfrom()
708.16.
select()
728.17.
setsockopt()
,
getsockopt()
748.18.
send()
,
sendto()
768.19.
shutdown()
788.20.
socket()
798.21.
struct sockaddr_in
,
struct in_addr
80
9. More References.....................................................................................................................81
9.1. Books819.2. Web References819.3. RFCs82
Index83
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...

Puis-je vous offrir a boire?

J'ai trouve un bon nombre de choses intresting ici.

you people need to get a life

Puis-je vous offrir a boire?

what is this all about?

very clearly expressed information

Il est DIFFICILE D'EMPLOYER bon contenu mais la navigation !

You must be to leave a comment.
Submit
Characters: ...