+ int ret = 0;
+ struct addrinfo *ip_src; // store the source ip info
+ struct addrinfo *ip_dst; // store the destination ip info
+
+#if defined(USING_WINSOCK) // for Windows (with MinGW)
+ // initialize winsock DLL
+ WSADATA wsaData;
+ int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
+ if( iResult != NO_ERROR ) {
+ report_error( "gr_udp_source WSAStartup", "can't open socket" );
+ }
+#endif
+
+ // Set up the address stucture for the source address and port numbers
+ // Get the source IP address from the host name
+ struct addrinfo hints;
+ memset( (void*)&hints, 0, sizeof(hints) );
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_protocol = IPPROTO_UDP;
+ char port_str[7];
+ sprintf( port_str, "%d", port_src );
+ ret = getaddrinfo( src, port_str, &hints, &ip_src );
+ if( ret != 0 )
+ report_error("gr_udp_source/getaddrinfo",
+ "can't initialize source socket" );
+
+ // Get the destination IP address from the host name
+ sprintf( port_str, "%d", port_dst );
+ ret = getaddrinfo( dst, port_str, &hints, &ip_dst );
+ if( ret != 0 )
+ report_error("gr_udp_source/getaddrinfo",
+ "can't initialize destination socket" );