私はマップを宣言しました:
std::map <std::string, int> mymap;
*vit
上記のマップに2 つの値を挿入hit->first
し、ソケット経由で送受信したいと考えてい
ます。
私のコード:
for (std::map < int, std::vector < std::string > >::iterator hit = three_highest.begin(); hit != three_highest.end(); ++hit) {
for (std::vector < std::string >::iterator vit = (*hit).second.begin(); vit != (*hit).second.end(); vit++) {
std::cout << hit->first << ":";
std::cout << *vit << "\n";
mymap.insert( std::pair<std::string,int> (*vit,hit->first)); //Is it correct way
}
}
//その後、ソケット経由で送信
if ((bytecount = send(*csock, mymap , sizeof(mymap), 0)) == -1) { // I think this is wrong, Can someone correct it?
fprintf(stderr, "Error sending data %d\n", errno);
goto FINISH;
}
そして、受信側でこれら2つの変数を取り戻す方法は?
std::map <std::string, int> mymap;
if((bytecount = recv(hsock, mymap, sizeof(mymap), 0))== -1){ //Needs help here also
// getting mymap->first, mymap->second.
fprintf(stderr, "Error receiving data %d\n", errno);
}