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. CWinThread exits when calling recvfrom

CWinThread exits when calling recvfrom

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingquestion
2 Posts 2 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
    CND
    wrote on last edited by
    #1

    Hi, I'm using a CWinThread to send and recieve ICMP packets (pings). but while recieving the echo replys the thread exits. Thats the code I'm calling: char* echoReply = new char[50]; int nRet; int nAddrLen = sizeof(struct sockaddr_in); sockaddr_in lpsaFrom; lpsaFrom.sin_family = AF_INET; lpsaFrom.sin_port = 0; lpsaFrom.sin_addr.s_addr = inet_addr("192.168.6.100"); // Recieve the echo reply nRet = recvfrom(s, echoReply, sizeof(echoReply), 0, (sockaddr*) &lpsaFrom, &nAddrLen); when calling recvfrom() the thread breaks down. even the debugger does not stop at any breakpoints i have set after the recvfrom call. has anybody an idea? PS: recv also doesn't work and bind works fine...

    R 1 Reply Last reply
    0
    • C CND

      Hi, I'm using a CWinThread to send and recieve ICMP packets (pings). but while recieving the echo replys the thread exits. Thats the code I'm calling: char* echoReply = new char[50]; int nRet; int nAddrLen = sizeof(struct sockaddr_in); sockaddr_in lpsaFrom; lpsaFrom.sin_family = AF_INET; lpsaFrom.sin_port = 0; lpsaFrom.sin_addr.s_addr = inet_addr("192.168.6.100"); // Recieve the echo reply nRet = recvfrom(s, echoReply, sizeof(echoReply), 0, (sockaddr*) &lpsaFrom, &nAddrLen); when calling recvfrom() the thread breaks down. even the debugger does not stop at any breakpoints i have set after the recvfrom call. has anybody an idea? PS: recv also doesn't work and bind works fine...

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      This may not fix the problem but... sizeof(echoReply) will return 4 (the size of the pointer), not 50. You need to specify 50 instead of sizeof(echoReply).

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      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