Change around names in test directory - sorry bert
This commit is contained in:
parent
7ce2cb815d
commit
5304a18002
5
.gitignore
vendored
5
.gitignore
vendored
@ -17,8 +17,9 @@ ev/config.log
|
||||
ev/config.status
|
||||
ev/libtool
|
||||
ev/stamp-h1
|
||||
test/echo-server
|
||||
ev/autom4te.cache
|
||||
/ipch/
|
||||
/Debug/
|
||||
/Release/
|
||||
/Release/
|
||||
|
||||
test/echo-demo
|
||||
|
||||
9
Makefile
9
Makefile
@ -1,11 +1,14 @@
|
||||
test/echo-server: test/echo-server.c ol.a
|
||||
$(CC) -ansi -g -o test/echo-server test/echo-server.c ol.a -lm
|
||||
test/echo-demo: test/echo-demo.c test/echo.o ol.a
|
||||
$(CC) -ansi -g -o test/echo-demo test/echo-demo.c test/echo.o ol.a -lm
|
||||
|
||||
ol.a: ol-unix.o ev/ev.o
|
||||
$(AR) rcs ol.a ol-unix.o ev/ev.o
|
||||
|
||||
ol-unix.o: ol-unix.c ol.h ol-unix.h
|
||||
$(CC) -ansi -g -c ol-unix.c -o ol-unix.o -lm
|
||||
$(CC) -ansi -g -c ol-unix.c -o ol-unix.o
|
||||
|
||||
test/echo.o: test/echo.c test/echo.h
|
||||
$(CC) -ansi -g -c test/echo.c -o test/echo.o
|
||||
|
||||
ev/ev.o: ev/config.h ev/ev.c
|
||||
$(MAKE) -C ev
|
||||
|
||||
15
test/echo-demo.c
Normal file
15
test/echo-demo.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include "../ol.h"
|
||||
#include "echo.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
ol_init();
|
||||
|
||||
int r = echo_start(8000);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
|
||||
ol_run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -66,7 +66,7 @@ void on_accept(ol_handle* server, ol_handle* new_client) {
|
||||
|
||||
new_client->close_cb = on_close;
|
||||
|
||||
p = (peer_t*)malloc(sizeof(peer_t));
|
||||
p = (peer_t*)malloc(sizeof(peer_t));
|
||||
p->handle = new_client;
|
||||
p->buf.base = p->read_buffer;
|
||||
p->buf.len = BUFSIZE;
|
||||
@ -82,31 +82,25 @@ void on_accept(ol_handle* server, ol_handle* new_client) {
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
ol_handle* server;
|
||||
struct sockaddr_in addr;
|
||||
int r;
|
||||
int echo_start(int port) {
|
||||
ol_handle* server = ol_tcp_handle_new(on_close, NULL);
|
||||
|
||||
ol_init();
|
||||
struct sockaddr_in addr = ol_ip4_addr("0.0.0.0", port);
|
||||
|
||||
server = ol_tcp_handle_new(on_close, NULL);
|
||||
|
||||
addr = ol_ip4_addr("0.0.0.0", 8000);
|
||||
|
||||
r = ol_bind(server, (struct sockaddr*) &addr);
|
||||
int r = ol_bind(server, (struct sockaddr*) &addr);
|
||||
if (r) {
|
||||
/* TODO: Error codes */
|
||||
fprintf(stderr, "Bind error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
r = ol_listen(server, 128, on_accept);
|
||||
if (r) {
|
||||
/* TODO: Error codes */
|
||||
fprintf(stderr, "Listen error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ol_run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
3
test/echo.h
Normal file
3
test/echo.h
Normal file
@ -0,0 +1,3 @@
|
||||
#include "../ol.h"
|
||||
|
||||
int echo_start(int port);
|
||||
Loading…
Reference in New Issue
Block a user