Go to Post That wiring job is so sexy I would date it. - RoboChair [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Spotlight this post!  
Unread 01-15-2009, 01:21 AM
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
Re: Getting Live Feed from Axis Camera in Windriver

Quote:
Originally Posted by wt200999 View Post
I was getting the EADDRINUSE thing when I was declaring PCVideoServer as a pointer and making it on the heap. That error stopped when I just declared it on the stack

Code:
PCVideoServer pc;
however I have no idea what that error means
EADDRINUSE is a POSIX error type that is returned when you try to bind an IP socket to a port/address combination that is already in use. For example, if you try to run two web servers on port 80 on your server, only the first instance will be able to bind a socket to port 80, and the other will return as an error with errno EADDRINUSE.

What's happening in your case is that when you declare PCVideoServer on the heap (with new), you bind the video server port on the cRIO, but you never actually delete the PCVideoServer object before your user program completes. Only when the destructor method of PCVideoServer is called is the port actually released:

Code:
void server_heap_bad()
{
   PCVideoServer *server = new PCVideoServer();
   // when this function returns, you lose the pointer to the PCVideoServer object.
   // The PCVideoServer object remains allocated and active, but you can no
   // longer deallocate it because you don't know where it is (this is called a
   // "dangling pointer" error).
   // Thus the video port remains bound until you reboot the cRIO.
}

void server_heap_good()
{
   PCVideoServer *server = new PCVideoServer();
   
   //... do stuff
   delete server; // calls PCVideoServer::~PCVideoServer, which unbinds the port.
}

void server_stack_good()
{
   PCVideoServer server;

   // when this function returns, the server instance is automatically destroyed
   // without the need for delete.  Thus the port will be unbound.
}
Hope this makes sense; in most modern operating systems, the operating system would perform garbage collection on all open handles, including sockets, and eventually the port would automatically be unbound - but this behavior cannot be relied on and may not happen when you kill your project in Wind River.
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2009 - Live camera feed to drivers during a match? Travis Hoffman Rules/Strategy 23 01-21-2009 05:43 PM
Axis Camera responding in the Vision Assistant but not in WindRiver DanDon C/C++ 3 01-11-2009 12:50 PM
Getting Live Axis cam feed popo308 Programming 7 01-09-2009 07:14 PM
Anyone know how to get a live video feed from your axis cam? Jazonk FRC Control System 7 01-03-2009 08:08 PM
Getting feedback from Axis Camera?? *programming in C++* Straberrie Programming 3 01-01-2009 10:39 PM


All times are GMT -5. The time now is 09:41 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi