Carl Worth [Sat, 12 Nov 2005 01:21:21 +0000 (01:21 +0000)]
2005-11-11 Carl Worth <cworth@cworth.org>
* src/ttt-server.h:
* src/ttt-server.c: (ttt_server_init), (ttt_server_add_client),
(_accept_client), (main): Add a new ttt_server_t object with a
mutex-protected list of clients. Move client handling code down
into new ttt-client.c.
* src/ttt-client.h:
* src/ttt-client.c: (ttt_client_create), (ttt_client_destroy),
(ttt_client_handle_requests): New ttt_client_t object that simply
holds a pointer back to the server as well as the client socket
file descriptor.
* src/ttt-socket.h:
* src/ttt-socket.c: (ttt_socket_accept): Add closure argument. Add
a call to fork before calling the accept callback.
* src/ttt-args.c: Hide unused ttt_args_usage from the compiler to
keep it from complaining.
* src/ttt.c: (main): Rename the client main program from
ttt-client to ttt.c, (since the server code now has its own
ttt-client.c).
* src/ttt.h:
* src/Makefile.am: Include and link with pthread now that we have
pthread-based mutex locking.
Carl Worth [Wed, 9 Nov 2005 14:37:16 +0000 (14:37 +0000)]
2005-11-09 Carl Worth <cworth@cworth.org>
* src/Makefile.am:
* src/ttt.h:
* src/ttt-server.c: (ttt_dispatch), (main):
* src/ttt-socket.h:
* src/ttt-socket.c: (_sockaddr_init), (_wait_for_connection),
(ttt_socket_create_server), (ttt_socket_accept): Push a lot of
code out of ttt-server.c down into a new ttt_socket abstraction
layer. The code is much easier to read now. The server also no
longer exits when the first client exits, but continues to listen
for more connections.
Carl Worth [Sat, 5 Nov 2005 16:43:21 +0000 (16:43 +0000)]
2005-11-05 Carl Worth <cworth@cworth.org>
* src/Makefile.am: Add ttt-board.[ch] and x.[ch]
* src/ttt-board.h:
* src/ttt-board.c: (ttt_board_init), (ttt_board_init_from_string),
(ttt_board_to_string), (ttt_board_write): Add some stub functions
for Richard and Kevin to have some practice
implementing. Functions to represent a board and to go to/from a
string.
* src/x.h:
* src/x.c: (xasprintf), (xvasprintf), (xpipe), (xfork), (xmalloc),
(xcalloc), (xrealloc), (xfdopen), (xstrdup), (xfwrite): Several
utility functions that make system calls, check the result, and
exit on any error. This will simplify the error checking needed in
programs using these functions.