Subversion Repositories Mokou

Rev

Rev 8 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8 Rev 9
Line 1... Line 1...
1
/* $Id: server.c 8 2024-09-07 09:22:48Z nishi $ */
1
/* $Id: server.c 9 2024-09-07 09:25:26Z nishi $ */
2
 
2
 
3
#include "mk_server.h"
3
#include "mk_server.h"
4
 
4
 
5
#include "mk_service.h"
5
#include "mk_service.h"
6
#include "mk_version.h"
6
#include "mk_version.h"
Line 8... Line 8...
8
#include "mk_log.h"
8
#include "mk_log.h"
9
 
9
 
10
#include <stdio.h>
10
#include <stdio.h>
11
#include <stdlib.h>
11
#include <stdlib.h>
12
#include <unistd.h>
12
#include <unistd.h>
-
 
13
#include <poll.h>
13
 
14
 
14
#include <sys/types.h>
15
#include <sys/types.h>
15
#include <sys/socket.h>
16
#include <sys/socket.h>
16
#include <sys/un.h>
17
#include <sys/un.h>
17
 
18
 
Line 50... Line 51...
50
	char* ver = mk_strcat3("R", mk_get_version(), "\n");
51
	char* ver = mk_strcat3("R", mk_get_version(), "\n");
51
	char cbuf[2];
52
	char cbuf[2];
52
	cbuf[1] = 0;
53
	cbuf[1] = 0;
53
	char* str = malloc(1);
54
	char* str = malloc(1);
54
	str[0] = 0;
55
	str[0] = 0;
-
 
56
	struct pollfd pollfds[16 + 1];
-
 
57
	pollfds[0].fd = server;
-
 
58
	pollfds[0].events = POLLIN | POLLPRI;
55
	while(1){
59
	while(1){
56
		mk_log("Waiting for the connection");
60
		mk_log("Waiting for the connection");
-
 
61
		int r = poll(pollfds, 16 + 1, 5000);
57
		int cli = accept(server, (struct sockaddr*)&cun, &socklen);
62
		int cli = accept(server, (struct sockaddr*)&cun, &socklen);
58
		send(cli, ver, strlen(ver), 0);
63
		send(cli, ver, strlen(ver), 0);
59
		while(1){
64
		while(1){
60
			if(recv(cli, cbuf, 1, 0) <= 0) break;
65
			if(recv(cli, cbuf, 1, 0) <= 0) break;
61
			if(cbuf[0] == '\n'){
66
			if(cbuf[0] == '\n'){