2
* Copyright (C) 2004 Steve Harris
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* $Id: server_thread.c,v 1.1.1.1 2004/08/07 22:21:02 theno23 Exp $
23
#include <sys/types.h>
24
#include <sys/socket.h>
26
#include "lo_types_internal.h"
28
#include "lo/lo_throw.h"
30
static void thread_func(void *data);
32
lo_server_thread lo_server_thread_new(const char *port, lo_err_handler err_h)
34
lo_server_thread st = malloc(sizeof(struct _lo_server_thread));
35
st->s = lo_server_new(port, err_h);
48
void lo_server_thread_free(lo_server_thread st)
52
lo_server_thread_stop(st);
53
/* pthread_cancel(st->thread); */
55
lo_server_free(st->s);
60
lo_method lo_server_thread_add_method(lo_server_thread st, const char *path,
61
const char *typespec, lo_method_handler h,
64
return lo_server_add_method(st->s, path, typespec, h, user_data);
67
void lo_server_thread_start(lo_server_thread st)
72
pthread_create(&(st->thread), NULL, (void *)&thread_func, st);
76
void lo_server_thread_stop(lo_server_thread st)
86
int lo_server_thread_get_port(lo_server_thread st)
88
return lo_server_get_port(st->s);
91
char *lo_server_thread_get_url(lo_server_thread st)
93
return lo_server_get_url(st->s);
96
static void thread_func(void *data)
98
lo_server_thread st = (lo_server_thread)data;
101
lo_server_recv_noblock(st->s, 10);
106
void lo_server_thread_pp(lo_server_thread st)
111
/* vi:set ts=8 sts=4 sw=4: */