libevent가 Win32도 지원하나요?
글쓴이: purewell / 작성시간: 토, 2003/11/22 - 8:58오후
위의 홈페이지에서 소스를 받아서 M$ VC6/7으로 컴파일해보면
약간의 오류가 발생합니다.
'__func__' 문제인데 대충 해결하면 됩니다. 중요한게 아니라...
일단 위의 문제를 해결하고 나면, event_test.c를 아래와 같은
코드로 바꾸고 컴파일한 뒤 실행해보세요.
이론적으로는 콘솔 상에서 'telnet localhost 9999'하면
evAccept 함수가 실행되야 합니다.
그러나 ㅡ_-); 안 되는군요.
/* * Compile with: * cc -I/usr/local/include -o event-test event-test.c -L/usr/local/lib -levent */ #include <sys/types.h> #include <sys/stat.h> #ifndef WIN32 #include <sys/queue.h> #include <unistd.h> #include <sys/time.h> #else #pragma comment(lib, "ws2_32.lib") #include <winsock2.h> #include <windows.h> #endif #include <fcntl.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <event.h> void evAccept(int fd, short event, void* arg) { fprintf(stderr, "대략 새로운 접속\n"); } int main(void) { WSADATA data; int sock; struct sockaddr_in sa; struct event ev; WSAStartup(MAKEWORD(2,2), &data); sock = socket(AF_INET, SOCK_STREAM, 0); if (sock==-1) { fprintf(stderr, "소켓 생성 오류\n"); return 0; } memset(&sa, 0x00, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_port = htons(9999); if ( -1 == bind(sock, (struct sockaddr*)&sa, sizeof(sa)) ) { fprintf(stderr, "소켓 바인드 오류\n"); return 0; } if ( -1 == listen(sock, 15) ) { fprintf(stderr, "소켓 리슨 오류\n"); return 0; } event_init(); event_set(&ev, sock, EV_TIMEOUT|EV_WRITE|EV_READ|EV_PERSIST, evAccept, &ev); if ( event_add(&ev, NULL) ) { fprintf(stderr, "이벤트 추가 오류\n"); return 0; } event_dispatch(); return 0; }
참고로 위의 소스를 약간 수정해서 Linux에서 돌리면
원하는대로 돌아갑니다.
File attachments:
첨부 | 파일 크기 |
---|---|
![]() | 1.29 KB |
![]() | 85.53 KB |
Forums:
댓글 달기