Ejemplo n.º 1
0
void ConnManagerThread::connect()
{
    //connect MS async
    sock_ptr sockConnect(new ip::tcp::socket(m_Ios));
    sockConnect->async_connect(m_ToEndpoint,
                               boost::bind(&ConnManagerThread::onConnected,
                                    this,
                                    boost::asio::placeholders::error,
                                    sockConnect));
}
int
searchServerInfo(char* progName, char* serverAddress, char*  serverPort)
{




    /* Nom du fichier demandé */
    char* filename;

    /* Déclaration de la liste chainée contenant les noms des fichiers disponibles*/
    list ma_liste = NULL;



    /* Set connection with server */
    sockcli = sockConnect(serverAddress, serverPort);



    /* Get list of available files from server */
    ma_liste = getFilenameList(sockcli);


    /* Boucle infinie */
    while (true) {

        /* Print list of available files */
        printf("\n\n	 Fichiers disponibles\n\n");
        print_list(ma_liste);
        printf("\n");


        /* Select one file from the list */
        filename = menu_choice(ma_liste);


        /* Send the requested file to the server. */
        sendFilename(filename);


        /* Receive the file content from the server. */
        getFileContent(progName, filename, sockcli);

    }

    printf("\n[%ld] Fermeture de la socket.\n\n \n", (long int) getpid());
    close(sockcli);

    return EXIT_SUCCESS;
}
Ejemplo n.º 3
0
ITSocketClient::ITSocketClient(char *cfg_filepath)
{
	int i;
	FILE *fp;

	/* Load all IPADDR list*/
	if((fp = fopen(cfg_filepath, "r")) == NULL){
	 	fprintf(stderr,"invalid filename\n");
	    exit(2);
	}
	
	if(fgets(dstAddrTemp, STR_MAX, fp)==NULL){
	    exit(2);
	}
	if(fgets(dstPortTemp, STR_MAX, fp)==NULL){
	    exit(2);
	}
	dstAddrTemp[strlen(dstAddrTemp)-1] = '\0';
	dstPortTemp[strlen(dstPortTemp)-1] = '\0';
	fclose(fp);
	sockConnect();
}