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. Probllem related to recv() function in winsock.h header fle

Probllem related to recv() function in winsock.h header fle

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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.
  • R Offline
    R Offline
    Raghavendra Pise
    wrote on last edited by
    #1

    Hi Friends, In socket programming I want to connect double byte charcters. Earlier we used recv() function for single byte charcter. If we use double byte chracter in below recv function, its coming as a question mark symbol. If anybody knows how can I handle double byte charcter in Scoket programing(recv function),Please let me know. My codesnippet: while( bytesRecv == SOCKET_ERROR ) { bytesRecv = recv( ConnectSocket, recvbuf, 64, 0 ); if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET || CheckTimeOut()) { return CloseListen(); } } Note:Here recvbuf works for singel byte not for doublebyte charcters. Thanks in advance.

    L M 2 Replies Last reply
    0
    • R Raghavendra Pise

      Hi Friends, In socket programming I want to connect double byte charcters. Earlier we used recv() function for single byte charcter. If we use double byte chracter in below recv function, its coming as a question mark symbol. If anybody knows how can I handle double byte charcter in Scoket programing(recv function),Please let me know. My codesnippet: while( bytesRecv == SOCKET_ERROR ) { bytesRecv = recv( ConnectSocket, recvbuf, 64, 0 ); if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET || CheckTimeOut()) { return CloseListen(); } } Note:Here recvbuf works for singel byte not for doublebyte charcters. Thanks in advance.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Raghavendra Pise wrote:

      Note:Here recvbuf works for singel byte not for doublebyte charcters.

      You need to do some studying on character encoding, thinks like Unicode etc. Here is just one example[^]

      1 Reply Last reply
      0
      • R Raghavendra Pise

        Hi Friends, In socket programming I want to connect double byte charcters. Earlier we used recv() function for single byte charcter. If we use double byte chracter in below recv function, its coming as a question mark symbol. If anybody knows how can I handle double byte charcter in Scoket programing(recv function),Please let me know. My codesnippet: while( bytesRecv == SOCKET_ERROR ) { bytesRecv = recv( ConnectSocket, recvbuf, 64, 0 ); if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET || CheckTimeOut()) { return CloseListen(); } } Note:Here recvbuf works for singel byte not for doublebyte charcters. Thanks in advance.

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

        In addition to led mike's reply... Sockets work in bytes, that's it.  If you need to work with any other types then you need to do the multiplication yourself to calculate the number of bytes for a given type. recv() is confusing with its char* type - it actually has nothing to do with "characters" - it's just what the BYTE type was at the time it was designed.  It's ancient, and most wish it would go away. Mark

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

        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