#include #include #include #include #include #include #include #include #include #include struct scot_socket * sock; struct scot_socket * con_sock; void on_exit_func (void) { if (con_sock != NULL) scot_socket_free (con_sock); scot_socket_free (sock); exc_end (); } void exit_func (int inum) { exit (0); } int main (int argc, char * argv []) { excenv_t * ee; signal (SIGINT, exit_func); atexit (on_exit_func); TRY { sock = scot_socket_un_new ("/tmp/socket"); scot_socket_listen (sock); } CATCH (ee) { exception_t *e; while (e = retrive_exception (ee)) { print_exception (e); if (EXC_IN_THIS_TRY (e)) { switch (exc_errnum_get (e)) { case SCOT_SOCKET_LISTEN_FAIL: scot_socket_free (sock); case SCOT_SOCKET_NEW_FAIL: break; } } free_exception (e); } free_catched (ee); } TRY { while ((con_sock = scot_socket_accept (sock)) >= 0) { struct scot_stream * sock_stream; int i, n; char puffer [1024]; sock_stream = (struct scot_stream *) con_sock; while ((n = recv (sock_stream->handle.sock, puffer, 1024, 0)) > 0) { printf ("Server: "); if (puffer [0] == 'q') break; for (i=0; i