2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
12 #include "host_socket.h"
16 static struct SocketController ctl
;
18 static DWORD WINAPI
ResolverThread(struct SocketController
*ctl
)
20 D(printf("[Resolver] Thread started\n"));
24 WaitForSingleObject(ctl
->ResolverEvent
, INFINITE
);
28 case SOCK_CMD_SHUTDOWN
:
29 D(printf("[Resolver] Shutdown requested\n"));
31 CloseHandle(ctl
->ResolverEvent
);
36 KrnCauseIRQ(ctl
->ResolverIRQ
);
40 struct SocketController
* __declspec(dllexport
) __aros
sock_init(void)
42 struct WSAData wsdata
;
45 int state
= WSAStartup(0x0002, &wsdata
);
47 D(printf("[sock_init] WSAStartup reply: %u\n", state
));
48 D(printf("[sock_init] Using WinSock v%u.%u (%s)\n", wsdata
.wVersion
& 0x00FF, wsdata
.wVersion
>> 8, wsdata
.szDescription
));
49 D(printf("[sock_init] Status: %s\n", wsdata
.szSystemStatus
));
61 ctl
.ResolverIRQ
= irq
;
63 ctl
.ResolverEvent
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
64 if (ctl
.ResolverEvent
)
68 thread
= CreateThread(NULL
, 0, (LPTHREAD_START_ROUTINE
)ResolverThread
, &ctl
, 0, &id
);
73 ctl
.SocketEvent
= KrnGetIRQObject(ctl
.SocketIRQ
);
76 CloseHandle(ctl
.ResolverEvent
);
79 KrnFreeIRQ(ctl
.SocketIRQ
);
85 int __declspec(dllexport
) __aros
sock_shutdown(struct SocketController
*ctl
)
87 int res
= WSACleanup();
92 ctl
->Command
= SOCK_CMD_SHUTDOWN
;
93 SetEvent(ctl
->ResolverEvent
);
95 KrnFreeIRQ(ctl
->ResolverIRQ
);
96 KrnFreeIRQ(ctl
->SocketIRQ
);