source: neercs/trunk/src/mini-server.c @ 4379

Last change on this file since 4379 was 4379, checked in by Sam Hocevar, 10 years ago

Networking tests. Doesn't work yet.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1/*
2 *  neercs        console-based window manager
3 *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
4 *                2008-2010 Jean-Yves Lamoureux <jylam@lnxscene.org>
5 *                2008-2010 Pascal Terjan <pterjan@linuxfr.org>
6 *                All Rights Reserved
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15#if defined HAVE_CONFIG_H
16#   include "config.h"
17#endif
18
19#include <stdio.h> /* BUFSIZ */
20
21#include "mini-neercs.h"
22#include "mini-socket.h"
23
24static nrx_socket_t *insock, *outsock;
25
26void server_init(void)
27{
28    insock = socket_open("/tmp/neercs.sock", 1);
29}
30
31int server_step(void)
32{
33    int ret = socket_select(insock, 10000);
34
35    if (ret > 0)
36    {
37        char buf[BUFSIZ];
38        ssize_t bytes = socket_read(insock, buf, BUFSIZ);
39        if (bytes > 0)
40        {
41            fprintf(stderr, "read: %s\n", buf);
42            return 0;
43        }
44    }
45//else fprintf(stderr, "no data \n");
46
47    return 1;
48}
49
50void server_fini(void)
51{
52    socket_close(insock);
53}
54
Note: See TracBrowser for help on using the repository browser.