blob: 892d9abb72b66ed920877c619b0d2d8b12def055 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#undef __CRT__NO_INLINE
#define __CRT__NO_INLINE
#include <winsock2.h>
#include <wspiapi.h>
struct addrinfo * WINAPI
WspiapiNewAddrInfo (int iSocketType, int iProtocol, WORD wPort, DWORD dwAddress)
{
struct addrinfo *n;
struct sockaddr_in *pa;
if ((n = (struct addrinfo *) WspiapiMalloc (sizeof (struct addrinfo))) == NULL)
return NULL;
if ((pa = (struct sockaddr_in *) WspiapiMalloc (sizeof(struct sockaddr_in))) == NULL)
{
WspiapiFree(n);
return NULL;
}
pa->sin_family = AF_INET;
pa->sin_port = wPort;
pa->sin_addr.s_addr = dwAddress;
n->ai_family = PF_INET;
n->ai_socktype = iSocketType;
n->ai_protocol = iProtocol;
n->ai_addrlen = sizeof (struct sockaddr_in);
n->ai_addr = (struct sockaddr *) pa;
return n;
}
|