|
TCP Socket - C Language
|
Vai al codice sorgente di questo file.
Funzioni | |
| int | main (int argc, char *argv[]) |
This program is free software; you can redistribuite it and/or modify it under the terms of the GNU/General Pubblic License as published the Free software Foundation; either version 2 of the License, or (at your opinion) any later version.
Definizione nel file clientSSL.c.
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
client di esempio
Definizione alla linea 20 del file clientSSL.c.
{
message_t msg;
char * hostname;
char * service;
int sent;
cli_conn * client;
char messaggio[32768];
hostname = "localhost";
service = "12100";
/* Apro la socket di comunicazione col server */
if ((client = retrySSLConnection(hostname, service)) == NULL) {
sys_err(__FILE__,__LINE__,"Client: Errore nella apertura del socket di comunicazione");
exit(EXIT_FAILURE);
}
/* Preparo il messaggio da inviare al server
* Abbastanza grande da forzare due read nella commSSL.c
* */
msg.type = MSG_PRINT;
msg.length = 32768;
memset(&messaggio, 65, 32768);
msg.buffer = messaggio;
/* invio un messaggio */
if ((sent = sendSSLMessage(client, &msg)) == -1){
if (client->socket != -1) closeSSLConnection(client);
exit(EXIT_FAILURE);
}
/* ricevo la risposta */
if (receiveSSLMessage(client, &msg) == -1){
if (client->socket != -1) closeSSLConnection(client);
exit(EXIT_FAILURE);
}
if (msg.type==MSG_OK)
printf("Client: conferma ricezione messaggio\n");
else{
fprintf(stderr,"Client: messaggio non riconosciuto\n");
closeSSLConnection(client);
exit(EXIT_FAILURE);
}
/* Chiudo la socket di comunicazione del client */
closeSSLConnection(client);
unloadSSL();
return 0;
}