Note that there are some explanatory texts on larger screens.

plurals
  1. POWin32 C++ sendto() Returns Error 8 : WSA_NOT_ENOUGH_MEMORY
    primarykey
    data
    text
    <p>I have a program that detects keyboard inputs on my computer and sends them to my Android phone via UDP. The Android phone then takes the UDP packet and logs every key hit in a text file, but that's besides the point. I am currently using the standard Win32 API in order to send the packets via the sendto() function and WSAStartup. However, all of a sudden sendto() keeps returning an error of 8 which, according to MSDN, means WSA_NOT_ENOUGH_MEMORY. Now I have an idea of what that means, but I don't understand how to change my program to fix it, considering I changed nothing and it just started doing it. Restarting my computer has not helped. Here is what the UDP packet send function looks like. Maybe you guys can help me. Note that this is a thread function. Aren't threads dedicated a certain amount of memory according to the programmer? Could this be the issue?</p> <p>Edit: This error is received on the PC SENDING the packets, not the phone. Wireshark will not pick up the packing leaving the PC, even though it worked before getting this error.</p> <p>Thank you,</p> <pre><code>DWORD msgSender(LPVOID arg) { //Setup size_t pkt_length = PACKET_LENGTH; char pkt[PACKET_LENGTH]; sockaddr_in dest; sockaddr_in local; char inputAddr[] = "127.0.0.1"; char destAddr[] = "192.168.1.7"; WSACleanup(); WSADATA WsaData; WSAStartup(MAKEWORD(2,2), &amp;WsaData); local.sin_family = AF_INET; local.sin_addr.s_addr = inet_addr(inputAddr); local.sin_port = 8081; // choose any dest.sin_family = AF_INET; dest.sin_addr.s_addr = inet_addr(destAddr); dest.sin_port = htons(8080); // create the socket s = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); // bind to the local address bind( s, (sockaddr *)&amp;local, sizeof(local) ); while(true) { WaitForSingleObject(msgEvent, INFINITE); copyToPacket(keyStr, pkt); int ret = sendto( s, pkt, pkt_length, 0, (sockaddr*)&amp;dest, sizeof(dest)); keyReceived = false; } return 1; } void copyToPacket(string str, char* packet) { for(int i = 0; i &lt; str.length() &amp;&amp; i &lt; PACKET_LENGTH; i++) { packet[i] = str[i]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload