Cirrus Logic CS485 Bedienungsanleitung Seite 48

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 67
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 47
CS485G Spring 2015 48
(b) connect() to attach the socket to the server (like “call a num-
ber”).
5. Server
(a) socket() to create a local file descriptor (“buy a phone”).
(b) bind() to bind a name to the socket (“get a phone number”).
(c) listen() to wait for a client to connect (“plug in the phone”)
(d) accept() to create a file descriptor for this connection (“an-
swer the phone”)
6. The book provides some nicer routines that handle errors and com-
bine operations.
(a) Client: open clientfd() (combines socket() and connect())
(b) Server: open listenfd() (combines socket(), bind(), and
listen()), then accept()
7. Generic socket address structure (used for connect(), bind(), and
accept()
1 struct sockaddr {
2 unsigned short sa_family; /
*
protocol
*
/
3 char sa_data[14]; /
*
address data
*
/
4 };
8. Specific socket address structure for the internet
1 struct sockaddr_in {
2 unsigned short sin_family; /
*
AF_INET
*
/
3 unsigned short sin_port; /
*
net order
*
/
4 struct in_addr sin_addr; /
*
net order
*
/
5 unsigned char sin_zero[8]; /
*
pad
*
/
6 };
Seitenansicht 47
1 2 ... 43 44 45 46 47 48 49 50 51 52 53 ... 66 67

Kommentare zu diesen Handbüchern

Keine Kommentare