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. WinSock2 help!

WinSock2 help!

Scheduled Pinned Locked Moved C / C++ / MFC
helpdesign
6 Posts 5 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.
  • F Offline
    F Offline
    Fareed Rizkalla
    wrote on last edited by
    #1

    I'm not that experienced with WinSock2 so forgive me for my bad ERROR_HANDLING. Currently I have this line of code, breaking my application!

    BytesReceived = recv(IPv4, Data, sizeof(Data), 0);

    Yet I believe the worst case scenario the receive buffer would be empty and BytesReceived will be -1. Unless their is a bigger picture missing, could you give me a heads up! I'm currently using the HTTP protocol with blocking sockets! If you think it's a bad design strategy, please inform me! 1) send HTTP request 2) receive HTTP response 3) buffer[512] bytes, so HTTP response + data, separate them

    _ 1 Reply Last reply
    0
    • F Fareed Rizkalla

      I'm not that experienced with WinSock2 so forgive me for my bad ERROR_HANDLING. Currently I have this line of code, breaking my application!

      BytesReceived = recv(IPv4, Data, sizeof(Data), 0);

      Yet I believe the worst case scenario the receive buffer would be empty and BytesReceived will be -1. Unless their is a bigger picture missing, could you give me a heads up! I'm currently using the HTTP protocol with blocking sockets! If you think it's a bad design strategy, please inform me! 1) send HTTP request 2) receive HTTP response 3) buffer[512] bytes, so HTTP response + data, separate them

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      What do you mean by break?

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      N M 2 Replies Last reply
      0
      • _ _Superman_

        What do you mean by break?

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        N Offline
        N Offline
        Nemanja Trifunovic
        wrote on last edited by
        #3

        «_Superman_» wrote:

        What do you mean by break?

        Die?

        utf8-cpp

        1 Reply Last reply
        0
        • _ _Superman_

          What do you mean by break?

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          M Offline
          M Offline
          Moak
          wrote on last edited by
          #4

          «_Superman_» wrote:

          What do you mean by break?

          Someone said coffee break? :)

          Chat in Europe :java: Now with 24% more Twitter

          F 1 Reply Last reply
          0
          • M Moak

            «_Superman_» wrote:

            What do you mean by break?

            Someone said coffee break? :)

            Chat in Europe :java: Now with 24% more Twitter

            F Offline
            F Offline
            Fareed Rizkalla
            wrote on last edited by
            #5

            Unhandled exception at 0x761ed252 in Win32.exe: 0xC0000005: Access violation writing location 0x00000000. Keeps pointing at the recv function line! Update: WriteFile(File, Data, BytesReceived, NULL, NULL); This line is causing the trouble, but can't identify the problem! File is the CreateFile handle. Data is the recv buffer from WinSock2. BytesReceived is in the int returned by recv. :confused:

            modified on Tuesday, May 4, 2010 9:25 PM

            P 1 Reply Last reply
            0
            • F Fareed Rizkalla

              Unhandled exception at 0x761ed252 in Win32.exe: 0xC0000005: Access violation writing location 0x00000000. Keeps pointing at the recv function line! Update: WriteFile(File, Data, BytesReceived, NULL, NULL); This line is causing the trouble, but can't identify the problem! File is the CreateFile handle. Data is the recv buffer from WinSock2. BytesReceived is in the int returned by recv. :confused:

              modified on Tuesday, May 4, 2010 9:25 PM

              P Offline
              P Offline
              Parthiban
              wrote on last edited by
              #6

              Validate the "BytesReceived" variable(0 to 65535) and send it to the WriteFile fn. If u r passing the BytesToWrite as -1, than this will cause the overflow of DWORD variable which will exceeds the max value. ----Parthiban

              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