prefer211: переводы
Michael J. Donahoo "TCP/IP Sockets in C, 2nd Edition" / Michael J. Donahoo "Программирование TCP/IP сокетов в Си, 2-ое издание"
→Exercises
0 Задания ко 2-ой главе
→2.8 Communication
0 2.8 Передача данных
→int connect(int socket, const struct sockaddr *foreignAddress, socklen_t addressLength)
0 int connect(int socket, const struct sockaddr *foreignAddress, socklen_t addressLength)
→2.4 Specifying Addresses
0 2.4 Указание адресов
→2.3 Creating and Destroying Sockets
0 2.3 Создание и уничтожение сокетов
→% TCPEchoClient4 169.1.1.1 "Echo this!"
Received: Echo this!
Received: Echo this!
0 % TCPEchoClient4 169.1.1.1 "Echo this!"
Received: Echo this!
Received: Echo this!
→DieWithUserMessage(const char *msg, const char *detail)
DieWithSystemMessage(const char *msg)
DieWithSystemMessage(const char *msg)
0 DieWithUserMessage(const char *msg, const char *detail)
DieWithSystemMessage(const char *msg)
DieWithSystemMessage(const char *msg)
→DieWithMessage.c
1 #include
2 #include
3
4 void DieWithUserMessage(const char *msg, const char *detail) {
5 fputs(msg, stderr);
6 fputs(": ", stderr);
7 fputs(detail, stderr);
8 fputc('\n', stderr);
9 exit(1);
10 }
11
12 void DieWithSystemMessage(const char *msg) {
13 perror(msg);
14 exit(1);
15 }
DieWithMessage.c
1 #include
2 #include
3
4 void DieWithUserMessage(const char *msg, const char *detail) {
5 fputs(msg, stderr);
6 fputs(": ", stderr);
7 fputs(detail, stderr);
8 fputc('\n', stderr);
9 exit(1);
10 }
11
12 void DieWithSystemMessage(const char *msg) {
13 perror(msg);
14 exit(1);
15 }
DieWithMessage.c
0 DieWithMessage.c
1 #include
2 #include
3
4 void DieWithUserMessage(const char *msg, const char *detail) {
5 fputs(msg, stderr);
6 fputs(": ", stderr);
7 fputs(detail, stderr);
8 fputc('\n', stderr);
9 exit(1);
10 }
11
12 void DieWithSystemMessage(const char *msg) {
13 perror(msg);
14 exit(1);
15 }
DieWithMessage.c
1 #include
2 #include
3
4 void DieWithUserMessage(const char *msg, const char *detail) {
5 fputs(msg, stderr);
6 fputs(": ", stderr);
7 fputs(detail, stderr);
8 fputc('\n', stderr);
9 exit(1);
10 }
11
12 void DieWithSystemMessage(const char *msg) {
13 perror(msg);
14 exit(1);
15 }
DieWithMessage.c
→2. Report the name of the computer on which you are working by using the hostname
command.
command.
0 2. Узнайте имя компьютера, на котором Вы работаете, использовав команду hostname.
→1. Report your IP addresses using the ifconfig command in *NIX or the ipconfig command
in Windows. Identify the addresses that are IPv6.
in Windows. Identify the addresses that are IPv6.
0 1. Узнайте Ваш IP-адрес, используя команду ifconfig в *NIX или ipconfig в Windows. Определите Ваш IPv6-адрес.
→Earlier we said that a port identifies an application on a host. Actually, a port identifies a socket on a
host. There is more to it than this, however, because as Figure 1.2 shows, more than one socket
can be associated with one local port.
host. There is more to it than this, however, because as Figure 1.2 shows, more than one socket
can be associated with one local port.
0 Ранее мы сказали, что порт определяет приложение на хосте. На самом деле, порт определяет сокет на хосте. За этим скрывается нечто большее, нежели это, но все же, как показывает рисунок 1.2., более чем один сокет может ассоциироваться с одним локальным портом.
→Second, multiple programs can be using the same socket abstraction at the same time, although this is less
common. The figure shows that each socket has an associated local TCP or UDP port, which
is used to direct incoming packets to the application that is supposed to receive them.
common. The figure shows that each socket has an associated local TCP or UDP port, which
is used to direct incoming packets to the application that is supposed to receive them.
0 Второе - несколько программ могут одновременно использовать один и тот же сокет, хотя такое бывает редко. Рисунок показывает, что каждый сокет имеет связанный с ним локальный TCP или UDP порт, который используется для направления входящих пакетов к приложению, которе должно их получать.
→Figure 1.2 depicts the logical relationships among applications, socket abstractions,
protocols, and port numbers within a single host. There are several things to note about these
relationships. First, a program can have multiple sockets in use at the same time.
protocols, and port numbers within a single host. There are several things to note about these
relationships. First, a program can have multiple sockets in use at the same time.
0 Рисунок 1.2. показывает логические взаимосвязи между приложениями, сокетами, протоколами и номерами портов внутри одного хоста. Есть несколько вещей, которые необходимо отметить об этих взаимосвязях. Первое - программа может иметь несколько сокетов в использовании в одно и то же время.
→Stream and datagram sockets are also supported by other protocol suites, but this
book deals only with TCP stream sockets and UDP datagram sockets. A TCP/IP socket is
uniquely identified by an Internet address, an end-to-end protocol (TCP or UDP), and a port
number. As you proceed, you will encounter several ways for a socket to become bound to
an address.
book deals only with TCP stream sockets and UDP datagram sockets. A TCP/IP socket is
uniquely identified by an Internet address, an end-to-end protocol (TCP or UDP), and a port
number. As you proceed, you will encounter several ways for a socket to become bound to
an address.
0 Потоковый и дейтаграмные сокеты также поддерживаются другими наборами протоколов, но это книга описыват только потоковые сокеты TCP и дейтаграмные сокеты UDP. Сокет TCP/IP однозначно определяется интернет-адресом, сквозным протоколом (TCP или UDP) и номером порта. По мере прохождения данной книги, вы встретите несколько способов для того, чтобы привязать сокет к адресу.
→Different types of sockets correspond to different underlying protocol suites and differ-
ent stacks of protocols within a suite. This book deals only with the TCP/IP protocol suite.
The main types of sockets in TCP/IP today are stream sockets and datagram sockets. Stream
sockets use TCP as the end-to-end protocol (with IP underneath) and thus provide a reliable
byte-stream service.
ent stacks of protocols within a suite. This book deals only with the TCP/IP protocol suite.
The main types of sockets in TCP/IP today are stream sockets and datagram sockets. Stream
sockets use TCP as the end-to-end protocol (with IP underneath) and thus provide a reliable
byte-stream service.
1 Различные типы сокетов соответсвуют различным наборам протоколов и различным стекам протоколов. Эта книга описывает работу только с TCP/IP.
Основными типами сокетов в TCP/IP на сегодняшний день являются потоковые и дейтаграмные сокеты. Потоковые сокеты используют TCP как сквозной протокол (поверх IP) и таким образом обеспечивают сервис потоковой передачи байтов.
Основными типами сокетов в TCP/IP на сегодняшний день являются потоковые и дейтаграмные сокеты. Потоковые сокеты используют TCP как сквозной протокол (поверх IP) и таким образом обеспечивают сервис потоковой передачи байтов.
→TCPEchoServer4.c
0 TCPEchoServer4.c
→After reading this book, you’ll be able to write P2P applications just
as well as client-server.
as well as client-server.
0 После прочтения этой книги , Вы сможете писать приложения P2P наряду с клиент-серверными.
→So do you need to learn a different set
of technologies to program for P2P instead of client-server? No. In Sockets, client vs. server
merely distinguishes who makes the initial connection and who waits for connections. P2P
applications typically both initiate connections (to existing P2P nodes) and accept connections
(from other P2P nodes).
of technologies to program for P2P instead of client-server? No. In Sockets, client vs. server
merely distinguishes who makes the initial connection and who waits for connections. P2P
applications typically both initiate connections (to existing P2P nodes) and accept connections
(from other P2P nodes).
0 Так Вам необходимо изучить другой набор технологий для программирования для P2P вместо клиент-северного? Нет. При использовании сокетов клиент по сравнению с сервером отличается лишь тем, кто создает первоначальное соединение и кто ожидает соединения. Приложения P2P обычно как инициируют соединения (к существующим P2P узлам), так и принимают соединения (от других P2P узлов).
→In P2P,applications both consume and provide service, unlike the traditional client-server architecture
in which servers provide service and clients consume. In fact, P2P nodes are sometimes called
“servents,” combining the words server and client.
in which servers provide service and clients consume. In fact, P2P nodes are sometimes called
“servents,” combining the words server and client.
0 В P2P приложения и используют, и предоставляют сервисы, в отличие от традиционной клиент-серверной архитектуры, в которой сервер обеспечивает сервис, а клиент его использует. Узлы P2P иногда называют сервентами (комбинация слов "сервер" и "клиент").
→For example, port number 80 has been assigned to the Hyper-
Text Transfer Protocol (HTTP). When you run an HTTP client browser, it tries to contact the
Web server on that port by default. A list of all the assigned port numbers is maintained by
the numbering authority of the Internet (see http://www.iana.org/assignments/port-numbers).
You may have heard of an alternative to client-server called peer-to-peer (P2P).
Text Transfer Protocol (HTTP). When you run an HTTP client browser, it tries to contact the
Web server on that port by default. A list of all the assigned port numbers is maintained by
the numbering authority of the Internet (see http://www.iana.org/assignments/port-numbers).
You may have heard of an alternative to client-server called peer-to-peer (P2P).
0 К примеру, 80 порт предназначен для HTTP. Когда вы запускаете клиентский браузер HTTP, он пытается подсоединиться к веб-серверу на порт по умолчанию. Список всех выделенных номеров портов утверждается IANA (посетите http://www.iana.org/assignments/port-numbers).
Возможно, Вы слышали об альтернативе клиент-сервер, называмой peer-to-peer (P2P).
Возможно, Вы слышали об альтернативе клиент-сервер, называмой peer-to-peer (P2P).
Резюме
- Пол:
- мужчина
- Родной язык:
- русский
- С нами:
-
с 17 мая 2011 г.
(5631 день)
Не является членом клуба. - Деятельность:
-
295 версий перевода
с общим рейтингом 2
15 комментариев
Карма: 1 (оценок: 1)
