- struct sockaddr_in ipa;
- ipa.sin_family = AF_INET;
- ipa.sin_port = htons(NetworkController::port);
- ipa.sin_addr.s_addr = INADDR_ANY;
- memset(&ipa,0, sizeof ipa);
-
- if (bind(sfd, (struct sockaddr*)&sfd, sizeof sfd) == -1)
- {
- fprintf(stderr, "Server::Server - Couldn't bind to socket! Abort\n");
- close(sfd);
- sfd = -1;
- return;
- }
-
- //Listen for at most 1 connection
- if (listen(sfd, 1) == -1)
- {
- fprintf(stderr, "Server::Server - listening failed.\n");
- close(sfd);
- sfd = -1;
- return;
- }
-
- //Accept the connection
- sfd = accept(sfd, NULL, NULL);
- if (sfd < 0)
- {
- fprintf(stderr, "Server::Server - couldn't accept connection.\n");
- close(sfd);
- sfd = -1;
- return;
- }
-
- //We are now ready to play!
+ MovementResult result = controller->QueryMove(buffer);
+ network->SendMessage("%s", buffer.c_str());
+ return result;