5 #include "skelserver/skelserver.h"
7 #include "chargen/chargen.h"
9 int main(int argc
, char *argv
[])
11 PMYDATA pData
[MAX_THREADS
];
12 DWORD dwThreadId
[MAX_THREADS
];
13 HANDLE hThread
[MAX_THREADS
];
16 /* Create MAX_THREADS worker threads. */
17 for( i
=0; i
<MAX_THREADS
; i
++ )
19 /* Allocate memory for thread data. */
20 pData
[i
] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(MYDATA
));
25 /* Generate unique data for each thread. */
26 pData
[0]->Port
= ECHO_PORT
;
27 pData
[0]->Service
= EchoHandler
;
28 pData
[1]->Port
= CHARGEN_PORT
;
29 pData
[1]->Service
= ChargenHandler
;
31 hThread
[i
] = CreateThread(
32 NULL
, // default security attributes
33 0, // use default stack size
34 StartServer
, // thread function
35 pData
[i
], // argument to thread function
36 0, // use default creation flags
37 &dwThreadId
[i
]); // returns the thread identifier
39 /* Check the return value for success. */
40 if (hThread
[i
] == NULL
)
46 /* Wait until all threads have terminated. */
47 WaitForMultipleObjects(MAX_THREADS
, hThread
, TRUE
, INFINITE
);
49 /* Close all thread handles upon completion. */
50 for(i
=0; i
<MAX_THREADS
; i
++)
52 CloseHandle(hThread
[i
]);