I have a few questions. Server-client code with a (distributed) hash table. Give the peers their own port, own node-ID, predecessor and successor ( node-ID, IP and port of them).
That's a snippet of it.
port= argv[1];
ownNodeID = atoi(argv[2]);
sucNodeID = atoi(argv[3]);
sucIP = argv[4];
sucPort = argv[5];
preNodeID = atoi(argv[6]);
preIP = argv[7];
prePort = argv[8];
int sizeOfHashTable = (ownNodeID > preNodeID)? ownNodeID-preNodeID : preNodeID-ownNodeID;
entry hashtable[sizeOfHashTable];
for(i=0;i<sizeOfHashTable-1;i++){
hashtable[i].occupied=0;
hashtable[i].key=0;
hashtable[i].value=0;
}
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE;
So the first line takes are of the port. But why argv[1] ? Then all the suc, pre etc. So it also takes care of the predecessors and successors, right ? Then it defines the hash table.
But can someone please explain the snippet in a little more detail? And why do you use atoi and argv here?