MCPcopy Create free account
hub / github.com/data61/MP-SPDZ / start

Method start

Networking/Server.cpp:103–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void Server::start()
104{
105 int i;
106
107 names.resize(nmachines);
108 ports.resize(nmachines);
109
110 /* Set up the sockets */
111 socket_num.resize(nmachines);
112 for (i=0; i<nmachines; i++) { socket_num[i]=-1; }
113
114 // port number one lower to avoid conflict with players
115 server_socket = new ServerSocket(PortnumBase);
116 auto& server = *server_socket;
117 server.init();
118
119 // set up connections
120 for (i=0; i<nmachines; i++)
121 {
122 if (OnlineOptions::singleton.has_option("debug_networking"))
123 cerr << "Waiting for player " << i << endl;
124
125 socket_num[i] = server.get_connection_socket("P" + to_string(i));
126
127 if (OnlineOptions::singleton.has_option("debug_networking"))
128 cerr << "Connected to player " << i << endl;
129 }
130
131 // get names
132 for (i=0; i<nmachines; i++)
133 get_name(i);
134
135 // check setup, party 0 doesn't matter
136 bool all_on_local = true, none_on_local = true;
137 for (i = 1; i < nmachines; i++)
138 {
139 bool on_local = names[i].compare("127.0.0.1");
140 all_on_local &= on_local;
141 none_on_local &= not on_local;
142 }
143 if (not all_on_local and not none_on_local)
144 {
145 cout << "You cannot address Server.x by localhost if using different hosts" << endl;
146 exit(1);
147 }
148
149 // send names
150 send_names();
151
152 for (int i = 0; i < nmachines; i++)
153 close(socket_num[i]);
154}
155
156void* Server::start_in_thread(void* server)
157{

Callers 1

start_in_threadMethod · 0.45

Calls 6

has_optionMethod · 0.80
get_connection_socketMethod · 0.80
compareMethod · 0.80
to_stringFunction · 0.50
resizeMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected