diff --git a/phoned/Makefile b/phoned/Makefile index 4605031..bf45c30 100644 --- a/phoned/Makefile +++ b/phoned/Makefile @@ -1,10 +1,10 @@ # cnd Makefile # (C)2005, Dan Ponte -# $Amigan: phoned/phoned/Makefile,v 1.7 2005/06/02 02:45:35 dcp1990 Exp $ +# $Amigan: phoned/phoned/Makefile,v 1.8 2005/06/02 20:49:26 dcp1990 Exp $ include ../global.mk # basic stuff. we append for a reason. CPPFLAGS=-I../include -DDEBUG -DYY_NO_UNPUT -CFLAGS+=-g -Wall -W -ansi ${CPPFLAGS} +CFLAGS+=-g -Wall -W -ansi ${CPPFLAGS} -pthread LDFLAGS=-lutil # keep these up to date. MAINBIN=phoned diff --git a/phoned/notify.c b/phoned/notify.c index de6049d..d86778d 100644 --- a/phoned/notify.c +++ b/phoned/notify.c @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* $Amigan: phoned/phoned/notify.c,v 1.1 2005/06/02 02:40:53 dcp1990 Exp $ */ +/* $Amigan: phoned/phoned/notify.c,v 1.2 2005/06/02 20:49:26 dcp1990 Exp $ */ #include #include #include @@ -82,7 +82,7 @@ int cid_notify(cid_t* c) char* msg; int s; struct sockaddr_in sin; - short on = 0x1; + int on = 0x1; addrsll_t *cur; len = strlen(c->number) + strlen(c->name) + 8 + 5 + 4; msg = malloc(len * sizeof(char)); diff --git a/phoned/socket.c b/phoned/socket.c index 137eaf4..c97d0db 100644 --- a/phoned/socket.c +++ b/phoned/socket.c @@ -42,19 +42,24 @@ #include #include #include +#include +#include #include extern int modemfd; extern FILE* modem; -void handclient(sk) - int sk; +void *handclient(k) + void* k; { + int sk = (int)k; char buffer[1024]; int rlen; rlen = recv(sk, buffer, sizeof(buffer), 0); lprintf(debug, "Client said %s.", buffer); + close(sk); + return 0; } void network(void) /* name is misleading because we also do modem IO here */ @@ -62,6 +67,7 @@ void network(void) /* name is misleading because we also do modem IO here */ int s, /* us,*/ sn; fd_set fds; int sin_size, ilen; + pthread_t thr; char cbuf[1]; cbuf[0] = '\0'; cbuf[1] = '\0'; struct sockaddr_un it; @@ -98,14 +104,16 @@ void network(void) /* name is misleading because we also do modem IO here */ { if(FD_ISSET(s, &fds) != 0) { ilen = sizeof(it); - if((sn = accept(s, - (struct sockaddr *)&it, &ilen)) + if((sn = accept(s, (struct sockaddr *)&it, &ilen)) == -1) { - perror("s accept"); + lprintf(error, "accept: %s\n", + strerror(errno)); exit(-3); } - handclient(sn); - close(sn); + pthread_create(&thr, NULL, handclient, (void*)sn); + lprintf(info, "Incoming connection; child pid %d\n" + ,ilen); + } if(FD_ISSET(modemfd, &fds) != 0) {