Skip to content

BUG: evhttp can not callback with Windows and IOCP #709

@redfox1999

Description

@redfox1999

BUG: evhttp can not callback with Windows and IOCP

CAN NOT callback


void http_req_gencb(struct evhttp_request* req, void* arg) {

	struct evbuffer* buf = evbuffer_new();
	evbuffer_add_printf(buf, "<H1>Hello world!</H1>");
	evhttp_send_reply(req, HTTP_OK, "OK", buf);
	evbuffer_free(buf);
}

int main()
{
	WSADATA wsdata = {};
	WSAStartup(0x0202, &wsdata);

	evthread_use_windows_threads();
	struct event_config* cfg = event_config_new();
	event_config_set_flag(cfg, EVENT_BASE_FLAG_STARTUP_IOCP);
	event_config_set_num_cpus_hint(cfg, 8);
	struct event_base* base = event_base_new_with_config(cfg);
	event_config_free(cfg);
	
	struct evhttp* http = evhttp_new(base);
	evhttp_bind_socket(http, "0.0.0.0", 8001);
	evhttp_set_gencb(http, http_req_gencb, http);

	event_base_dispatch(base);

	event_base_free(base);

	WSACleanup();
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions