Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. UDP Application on Vista: Fail on sendto function

UDP Application on Vista: Fail on sendto function

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cris
    wrote on last edited by
    #1

    Hello, I have UDP app that works fine, except on Windows Vista. The error is WSAEINVAL (10022) on sendto function, and the package did not send :-( Anyone know this problem? Thanks, Cris.

    M D 2 Replies Last reply
    0
    • C Cris

      Hello, I have UDP app that works fine, except on Windows Vista. The error is WSAEINVAL (10022) on sendto function, and the package did not send :-( Anyone know this problem? Thanks, Cris.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Tough to guess without knowing the code :) Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      1 Reply Last reply
      0
      • C Cris

        Hello, I have UDP app that works fine, except on Windows Vista. The error is WSAEINVAL (10022) on sendto function, and the package did not send :-( Anyone know this problem? Thanks, Cris.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Cris wrote:

        The error is WSAEINVAL (10022) on sendto function...

        WSAEINVAL = "An unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled."


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        C 1 Reply Last reply
        0
        • D David Crow

          Cris wrote:

          The error is WSAEINVAL (10022) on sendto function...

          WSAEINVAL = "An unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled."


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          C Offline
          C Offline
          Cris
          wrote on last edited by
          #4

          This is my code: SOCKET m_maSocketOut; struct sockaddr_in m_SockAddrOut; unsigned long m_lInet; . . void init(CString strServer) { unsigned long lInet=0; memset(&m_SockAddrOut, 0, sizeof(m_SockAddrOut)); m_maSocketOut = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); m_SockAddrOut.sin_family = AF_INET; m_SockAddrOut.sin_port = htons(port); struct hostent FAR* hp = gethostbyname((char FAR *) (const char *) strServer); if (hp == NULL) { lInet = inet_addr((const char * ) strServer); if (lInet != INADDR_NONE) { validIP = TRUE; byAddress = TRUE; } } else validIP = TRUE; if (validIP) { if (byAddress) { m_SockAddrOut.sin_addr.s_addr = lInet; m_lInet = lInet; } else { m_SockAddrOut.sin_addr.s_addr = *((unsigned long far *) hp->h_addr); m_lInet = *((unsigned long far *) hp->h_addr); } if (m_maSocketOut != NULL) { bind(m_maSocketOut, (SOCKADDR*)& m_SockAddrOut, sizeof(m_SockAddrOut)); WSAAsyncSelect(m_maSocketOut, hWnd, WM_EXTERNA, FD_READ | FD_CLOSE); } } } void sendData(char szData[], int len) { int result = sendto(m_maSocketOut, (char FAR *) &szData, len, NULL, (PSOCKADDR) &m_SockAddrOut, sizeof(m_SockAddrOut)); m_SockAddrOut.sin_addr.s_addr = INADDR_ANY; if (result < 0) { int erroCode = WSAGetLastError(); //erroCode = 10022 in Windows Vista!! } } Important: This error code is only on Windows Vista, but not all instalations . I don't know which the exat situation, but I observed in Business and Ultimate version. Any idea?

          D 1 Reply Last reply
          0
          • C Cris

            This is my code: SOCKET m_maSocketOut; struct sockaddr_in m_SockAddrOut; unsigned long m_lInet; . . void init(CString strServer) { unsigned long lInet=0; memset(&m_SockAddrOut, 0, sizeof(m_SockAddrOut)); m_maSocketOut = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); m_SockAddrOut.sin_family = AF_INET; m_SockAddrOut.sin_port = htons(port); struct hostent FAR* hp = gethostbyname((char FAR *) (const char *) strServer); if (hp == NULL) { lInet = inet_addr((const char * ) strServer); if (lInet != INADDR_NONE) { validIP = TRUE; byAddress = TRUE; } } else validIP = TRUE; if (validIP) { if (byAddress) { m_SockAddrOut.sin_addr.s_addr = lInet; m_lInet = lInet; } else { m_SockAddrOut.sin_addr.s_addr = *((unsigned long far *) hp->h_addr); m_lInet = *((unsigned long far *) hp->h_addr); } if (m_maSocketOut != NULL) { bind(m_maSocketOut, (SOCKADDR*)& m_SockAddrOut, sizeof(m_SockAddrOut)); WSAAsyncSelect(m_maSocketOut, hWnd, WM_EXTERNA, FD_READ | FD_CLOSE); } } } void sendData(char szData[], int len) { int result = sendto(m_maSocketOut, (char FAR *) &szData, len, NULL, (PSOCKADDR) &m_SockAddrOut, sizeof(m_SockAddrOut)); m_SockAddrOut.sin_addr.s_addr = INADDR_ANY; if (result < 0) { int erroCode = WSAGetLastError(); //erroCode = 10022 in Windows Vista!! } } Important: This error code is only on Windows Vista, but not all instalations . I don't know which the exat situation, but I observed in Business and Ultimate version. Any idea?

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Could it be a UAC thing?


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            C 1 Reply Last reply
            0
            • D David Crow

              Could it be a UAC thing?


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              C Offline
              C Offline
              Cris
              wrote on last edited by
              #6

              No, the UAC configuration is not enabled.

              C 1 Reply Last reply
              0
              • C Cris

                No, the UAC configuration is not enabled.

                C Offline
                C Offline
                Cris
                wrote on last edited by
                #7

                I have solved the problem... removing the bind() function execution. Acording with the MSDN documentation: "The bind function is used on an unconnected socket before subsequent calls to the connect or listen functions. It is used to bind to either connection-oriented (stream) or connectionless (datagram) sockets. When a socket is created with a call to the socket function, it exists in a namespace (address family), but it has no name assigned to it. Use the bind function to establish the local association of the socket by assigning a local name to an unnamed socket." I understood that the bind function is not necessary, because I only want to send datagrams with a SOCKET to server and receive the responses by the same SOCKET, and the WSAAsyncSelect function grants the data response to the app. This is correct? Thanks, Cris.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups