Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change around names in test directory - sorry bert

  • Loading branch information...
commit 5304a18002d9348ae6bbde936452a117ab0702dc 1 parent 7ce2cb8
ry ry authored
5 .gitignore
View
@@ -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
View
@@ -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
View
@@ -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;
+}
20 test/echo-server.c → test/echo.c
View
@@ -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;
-
- ol_init();
+int echo_start(int port) {
+ ol_handle* server = ol_tcp_handle_new(on_close, NULL);
- server = ol_tcp_handle_new(on_close, NULL);
+ struct sockaddr_in addr = ol_ip4_addr("0.0.0.0", port);
- 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
View
@@ -0,0 +1,3 @@
+#include "../ol.h"
+
+int echo_start(int port);
Please sign in to comment.
Something went wrong with that request. Please try again.