Click here to Skip to main content
13,798,833 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I wrote a program for sending file use udt.sdk.4.7a.win32 but when I run it,a error message had occurred:
"A buffer overrun has occurred in udtreceivefile.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.
For more details please see Help topic 'How to debug Buffer Overrun Issues'"
And it stops at: _debugger_hook_dummy = 0 in this method:
void __cdecl _CRT_DEBUGGER_HOOK(int _Reserved)
{
  /* assign 0 to _debugger_hook_dummy so that the function is not folded in retail */
  (_Reserved);
  _debugger_hook_dummy = 0;
}


Please help me to solve it.
Posted 12-Nov-10 0:18am
Updated 12-Nov-10 0:21am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

You've given us nothing to go on. How about a call stack for starters...
 
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

Try to run aplication step by step (debug). You will get the line number in your code, where error occures. And then thy to check arguments of functions.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

please show your source code ..
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Ok.
My udtsendfile:
// udtsendfile.cpp : main project file.


#include "stdafx.h"
#include<iostream>
#include<udt.h>
#include<string.h>
#include<fstream>
#include<stdio.h>
using namespace std;
using namespace System;
using namespace System::Text;


int main()
{ 
 

   // use this function to initialize the UDT library
   UDT::startup();

   UDTSOCKET serv = UDT::socket(AF_INET, SOCK_STREAM, 0);

   int port = 9000;
   sockaddr_in my_addr;
   my_addr.sin_family = AF_INET;
   my_addr.sin_port = htons(9000);
   memset(&(my_addr.sin_zero), '\0', 8);

   if (UDT::ERROR == UDT::bind(serv, (sockaddr*)&my_addr, sizeof(my_addr)))
   {
      cout << "bind: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   
   }
   cout << "server is ready at port: " << port << endl;

   UDT::listen(serv, 10);

   sockaddr_in their_addr;
   int namelen = sizeof(their_addr);

   UDTSOCKET fhandle;

   if (UDT::INVALID_SOCK == (fhandle = UDT::accept(serv, (sockaddr*)&their_addr, &namelen)))
   {
      cout << "accept: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

    UDT::close(serv);

   // aquiring file name information from client
   char file[1024];
   int len;



   if (UDT::ERROR == UDT::recv(fhandle, (char*)&len, sizeof(int), 0))
   {
      cout << "recv: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }



   if (UDT::ERROR == UDT::recv(fhandle, file, len, 0))
   {
      cout << "recv: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }
   file[len] = '\0';

   // open the file
   fstream ifs(file, ios::in | ios::binary);

   ifs.seekg(0, ios::end);
   int64_t size = ifs.tellg();
   ifs.seekg(0, ios::beg);

   // send file size information
   if (UDT::ERROR == UDT::send(fhandle, (char*)&size, sizeof(int64_t), 0))
   {
      cout << "send: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   UDT::TRACEINFO trace;
   UDT::perfmon(fhandle, &trace);

   // send the file
   if (UDT::ERROR == UDT::sendfile(fhandle, ifs, 0, size))
   {
      cout << "sendfile: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   UDT::perfmon(fhandle, &trace);
   cout << "speed = " << trace.mbpsSendRate << "Mbits/sec" << endl;

   UDT::close(fhandle);

   ifs.close();

   // use this function to release the UDT library
   UDT::cleanup();

   return 1;
  
}



And my receivefile:
// udtreceivefile.cpp : main project file.


#include "stdafx.h"
#include<iostream>
#include<udt.h>
#include<string.h>
#include<fstream>
#include<stdio.h>
using namespace std;
using namespace System;

int main()
{
 

   // use this function to initialize the UDT library
   UDT::startup();

   UDTSOCKET fhandle = UDT::socket(AF_INET, SOCK_STREAM, 0);

   sockaddr_in serv_addr;
   serv_addr.sin_family = AF_INET;
    serv_addr.sin_port = htons(9000);

    serv_addr.sin_addr.S_un.S_un_b.s_b1=127;
    serv_addr.sin_addr.S_un.S_un_b.s_b2=0;
    serv_addr.sin_addr.S_un.S_un_b.s_b3=0;
    serv_addr.sin_addr.S_un.S_un_b.s_b4=1;
    memset(&(serv_addr.sin_zero), '\0', 8);

   if (UDT::ERROR == UDT::connect(fhandle, (sockaddr*)&serv_addr, sizeof(serv_addr)))
   {
      cout << "connect: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   // send name information of the requested file
   char filepath[]="C:\\t.txt";
   int len = strlen(filepath);

   if (UDT::ERROR == UDT::send(fhandle, (char*)&len, sizeof(int), 0))
   {
      cout << "send: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

    if (UDT::ERROR == UDT::send(fhandle, filepath, len, 0))
   {
      cout << "send: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   // get size information
   int64_t size;

   if (UDT::ERROR == UDT::recv(fhandle, (char*)&size, sizeof(int64_t), 0))
   {
      cout << "send: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   // receive the file
   char filenamen[]="t.txt";
   fstream ofs("t.txt", ios::out | ios::binary | ios::trunc);
   int64_t recvsize; 

   if (UDT::ERROR == (recvsize = UDT::recvfile(fhandle, ofs, 0, size)))
   {
      cout << "recvfile: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   UDT::close(fhandle);

   ofs.close();

   // use this function to release the UDT library
   UDT::cleanup();

   return 1;
}
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

I tried to run it. When I compiler source code of udt.sdk.4.7a.win32, I set agurment and a similar error had occured.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 7

Add /RTCs switch to the compiler. This will enable detection of buffer overruns and underruns at runtime. When overrun will be detected, program will break exactly in place where it happened rather than giving you postmortem message.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.181207.3 | Last Updated 19 Dec 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100