#include #include "winsock2.h" void MyTunnelManager:: OpenAndSendViaBluetooth(ViTEXT* szDsn) { WSADATA wsaData; SOCKET SendSocket; sockaddr_in RecvAddr; int Port = 27015; ViINT iBufLen; iBufLen = sizeof(szDsn); //--------------------------------------------- // Initialize Winsock WSAStartup(MAKEWORD(2,2), &wsaData); //--------------------------------------------- // Create a socket for sending data SendSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); //--------------------------------------------- // Set up the RecvAddr structure with the IP address of // the receiver (in this example case "123.456.789.1") // and the specified port number. RecvAddr.sin_family = AF_INET; RecvAddr.sin_port = htons(Port); RecvAddr.sin_addr.s_addr = inet_addr("192.168.18.20"); //RecvAddr.sin_addr.s_addr = inet_addr("122.168.18.20"); //--------------------------------------------- // Send a datagram to the receiver printf("Sending a telegramm to the receiver.%s..\n",szDsn); sendto(SendSocket, szDsn, iBufLen, 0, (SOCKADDR *) &RecvAddr, sizeof(RecvAddr)); //--------------------------------------------- // When the application is finished sending, close the socket. printf("Finished sending. Closing socket.\n"); closesocket(SendSocket); //--------------------------------------------- // Clean up and quit. printf("Exiting.\n"); WSACleanup(); }