Zilog EZ80F91AZA Manual do Utilizador Página 64

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 79
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 63
UM020107-1211 Creating SSL Applications
ZTP Network Security SSL Plug-In
User Manual
58
INT16 sockfd;
INT16 confd;
struct sockaddr_in server;
struct sockaddr_in client;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
server.sin_addr.s_addr = INADDR_ANY;
server.sin_family = AF_INET;
server.sin_port = intel16(0x1234);
bind(sockfd, (struct sockaddr *)&server, sizeof(struct
sockaddr_in));
listen(sockfd, 1);
This API opens the TCP socket and requests a server socket to be created on TCP port
0x1234. To create an SSL server application, the above code is modified, as shown in
the following code fragment:
INT16 sockfd;
INT16 confd;
struct sockaddr_in server;
struct sockaddr_in client;
sockfd = socket(AF_INET, SOCK_SSL, 0);
server.sin_addr.s_addr = INADDR_ANY;
server.sin_family = AF_INET;
server.sin_port = intel16(0x1234);
bind(sockfd, (struct sockaddr *)&server, sizeof(struct
sockaddr_in));
listen(sockfd, 1);
To accept a TCP-SSL connection from a remote client, the code informs the TCP
server to wait for an incoming TCP connection request, as shown in the following
example:
struct sockaddr_in client;
confd = accept(sockfd, (struct sockaddr *)&client, (INT16
*)&addrlen);
The same API is used to wait for an incoming SSL connection request. When a con-
nection is established, the SSL handshake is complete, and the
confd variable is
released to the application, which transfers the SSL data.
Vista de página 63
1 2 ... 59 60 61 62 63 64 65 66 67 68 69 ... 78 79

Comentários a estes Manuais

Sem comentários