[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r11177: Some misc libevent stuff I forgot. (in libevent-urz/trunk: . sample)



Author: Urz
Date: 2007-08-18 23:34:45 -0400 (Sat, 18 Aug 2007)
New Revision: 11177

Modified:
   libevent-urz/trunk/sample/IOCPloader-test.c
   libevent-urz/trunk/win_evbuffer.c
Log:
Some misc libevent stuff I forgot.

Modified: libevent-urz/trunk/sample/IOCPloader-test.c
===================================================================
--- libevent-urz/trunk/sample/IOCPloader-test.c	2007-08-19 03:00:03 UTC (rev 11176)
+++ libevent-urz/trunk/sample/IOCPloader-test.c	2007-08-19 03:34:45 UTC (rev 11177)
@@ -43,6 +43,15 @@
 #define BUF_SIZE 1000
 #define LISTEN_PORT 1025
 
+void printhex(char *data, size_t len) {
+     size_t i;
+     printf("[");
+     for(i = 0; i < (len-1); i++) {
+         printf("%x, ", (int) data[i]);
+     }
+     printf("%x ]\n", (int) data[len-1]);
+}
+
 void doexit(int val) {
     char data;
     fread(&data, 1, 1, stdin);

Modified: libevent-urz/trunk/win_evbuffer.c
===================================================================
--- libevent-urz/trunk/win_evbuffer.c	2007-08-19 03:00:03 UTC (rev 11176)
+++ libevent-urz/trunk/win_evbuffer.c	2007-08-19 03:34:45 UTC (rev 11177)
@@ -2,6 +2,9 @@
 #include "event.h"
 #include <stdio.h>
 #include "loaders/IOCPloader.h"
+#include <Winsock2.h>
+#include <Winsock.h>
+#include <mswsock.h>
 
 static char IOCPinit = 0;
 
@@ -60,7 +63,7 @@
 }
 // close
 int bufev_socket_close(int sock) {
-    if(close((SOCKET) sock) == SOCKET_ERROR) {
+    if(closesocket((SOCKET) sock) == SOCKET_ERROR) {
         return -1;
     } else {
         return 0;
@@ -75,10 +78,10 @@
     DWORD connTime;
     int size = sizeof(DWORD);
     
-    gsoRet = getsockopt((SOCKET) fd, SOL_SOCKET, SO_CONNECT_TIME, &connTime, &size);
+    gsoRet = getsockopt((SOCKET) fd, SOL_SOCKET, SO_CONNECT_TIME, (char *)&connTime, &size);
     /* Socket is not connected */
     if(gsoRet == SOCKET_ERROR) {
-        return -1;
+        return NULL;
     }
     
     if(!IOCPinit) {
@@ -107,7 +110,7 @@
 }
 
 void bufferevent_close_and_free(struct bufferevent *bufev) {
-    bufev_socket_close((int) bufev->connection_handle);
+    bufev_socket_close((int) ((struct sa_bufferevent *)bufev)->connection_handle);
     bufferevent_free(bufev);
 }