Notes On Codes And Codes

864 Words Nov 21st, 2014 4 Pages
/*s4304939 Assignment 4 CSSE2310 */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <stdio.h>
#include <signal.h>
#include "deck.h"
#include "herrs.h"
#include "game.h"

int accept_connections(int fds[], unsigned int count, struct sockaddr *addr, socklen_t *addrlen, portList* ports);

/* int accept_connections(int fds[], unsigned int count, struct sockaddr *addr, socklen_t *addrlen, portList* ports);
*/

game_t* global_game = 0; bool sigshutdown = false;

// Note, not closing the streams etc.
// Instead all we do is kill the other process, reap it
// and wait for the game to fall over from read fails
// The reason we don 't clean up more agressively is that
// the other code may still try to use it
// Yes we could just kill all the other processes and then
// call exit(). I 'm trying to show shutdown exiting from
// main void inthandle(int s) { if(global_game) { for (int i = 0; i < global_game->pcount; ++i) { reap_player(global_game->players[i]); } // now wait for the system to fall over } sigshutdown = true;
}

void read_from_tcp(int tcp, char *buffer) { int i = 0; while (recv(tcp, &buffer[i], 1, 0) > 0 && buffer[i] != ' ') { i++; } buffer[i] = ' ';
}
void add_client(int client_sock, portList* ports, int connectionFd) { char* gameN =…
Open Document