This commit is contained in:
manojampalam 2016-02-28 12:59:20 -08:00
parent 2c07012217
commit 720818154f
3 changed files with 14 additions and 10 deletions

View File

@ -32,13 +32,13 @@ int regular()
w32posix_initialize(); w32posix_initialize();
ZeroMemory(&hints, sizeof(hints)); ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_INET; //hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP; //hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE; hints.ai_flags = AI_PASSIVE;
// Resolve the server address and port // Resolve the server address and port
iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result); iResult = getaddrinfo("127.0.0.1", DEFAULT_PORT, &hints, &result);
if (iResult != 0) { if (iResult != 0) {
printf("getaddrinfo failed with error: %d\n", iResult); printf("getaddrinfo failed with error: %d\n", iResult);
w32posix_done(); w32posix_done();

View File

@ -99,7 +99,7 @@ namespace UnitTests
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE; // use my IP hints.ai_flags = AI_PASSIVE; // use my IP
if ((rv = getaddrinfo("127.0.0.1", PORT, &hints, &servinfo)) != 0) { if ((rv = getaddrinfo("::1", PORT, &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
return; return;
} }
@ -186,7 +186,8 @@ namespace UnitTests
//FD_SET(listen_fd, &read_set); //FD_SET(listen_fd, &read_set);
//FD_SET(connect_fd, &write_set); //FD_SET(connect_fd, &write_set);
HANDLE thread = CreateThread(NULL, 0, MyThreadFunction, &connect_fd, 0, NULL); //HANDLE thread = CreateThread(NULL, 0, MyThreadFunction, &connect_fd, 0, NULL);
//sin_size = sizeof(their_addr); //sin_size = sizeof(their_addr);
//accept_fd = accept(listen_fd, (struct sockaddr *)&their_addr, &sin_size); //accept_fd = accept(listen_fd, (struct sockaddr *)&their_addr, &sin_size);
@ -196,8 +197,11 @@ namespace UnitTests
ret = connect(connect_fd, servinfo->ai_addr, servinfo->ai_addrlen); ret = connect(connect_fd, servinfo->ai_addr, servinfo->ai_addrlen);
Assert::AreEqual(ret, 0, L"", LINE_INFO()); Assert::AreEqual(ret, 0, L"", LINE_INFO());
WaitForSingleObject(thread, INFINITE); MyThreadFunction(NULL);
CloseHandle(thread);
//WaitForSingleObject(thread, INFINITE);
//CloseHandle(thread);
int i = 9; int i = 9;
/* accept_fd = accept(listen_fd, (struct sockaddr *)&their_addr, &sin_size); /* accept_fd = accept(listen_fd, (struct sockaddr *)&their_addr, &sin_size);

View File

@ -93,7 +93,7 @@ int socketio_acceptEx(struct w32_io* pio) {
//create accepting socket //create accepting socket
//todo - get socket parameters from listening socket //todo - get socket parameters from listening socket
context->accept_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); context->accept_socket = socket(AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
if (context->accept_socket == INVALID_SOCKET) { if (context->accept_socket == INVALID_SOCKET) {
errno = errno_from_WSALastError(); errno = errno_from_WSALastError();
debug("ERROR:%d, io:%p", errno, pio); debug("ERROR:%d, io:%p", errno, pio);
@ -104,8 +104,8 @@ int socketio_acceptEx(struct w32_io* pio) {
context->accept_socket, context->accept_socket,
context->lpOutputBuf, context->lpOutputBuf,
0, 0,
sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in6) + 16,
sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in6) + 16,
&context->bytes_received, &context->bytes_received,
&pio->read_overlapped)) &pio->read_overlapped))
{ {