# How to start C++ GEV Server correctly using CVB SDK API

**URL:** https://forum.commonvisionblox.com/t/how-to-start-c-gev-server-correctly-using-cvb-sdk-api/463
**Category:** C-style API
**Tags:** gevserver
**Created:** [May 24, 2018, 9:46am UTC](https://forum.commonvisionblox.com/t/how-to-start-c-gev-server-correctly-using-cvb-sdk-api/463 "2018-05-24T09:46:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![zetazee85](https://avatars.discourse-cdn.com/v4/letter/z/b4bc9f/32.png) [@zetazee85](https://forum.commonvisionblox.com/u/zetazee85)
#### Post date: [May 24, 2018, 9:46am UTC](https://forum.commonvisionblox.com/t/how-to-start-c-gev-server-correctly-using-cvb-sdk-api/463/1 "2018-05-24T09:46:49Z")

</div>

Hi,

I am learning how to use the CVB SDK to create a GigE Vision Server to act as a Virtual Camera to send image over to an image acquisition client.

I am able to successfully use the C# CVB SDK to do so.  
However, when trying to replicate the same thing in C++ SDK, I am unable to use the CVB Management Console to discover the Virtual Camera, much less acquiring it.

I used netstat -an -u udp, and is able to see that port 3956 is started by the GEV server. However, CVB management console is not able to discover it.

Below is a snippet of my main C++ code:  
\*My C++ CVB project can be compiled successfully, and there are no exceptions when running the console application.

Any help or enlightenment on why I am not able to discover the GEV Virtual Camera is appreciated.

int main(int argc, char\* argv[])  
{  
cout \<\< “start gev server\n”;

```
IMG img;
cvbres_t nResult = LoadImageFile("%CVB%\\Tutorial\\ClassicSwitch.emu", img);
if (nResult < 0)
	throw std::exception();

TDriver nDriver = DT_Filter;
m_hGevServer = CreateGevServerEx(nDriver);

// configure server
nResult = GSSetImage(m_hGevServer, img);
if (nResult < 0)
	throw std::exception();

// set acquisition mode
TAcquisitionMode acqMode = AM_Automatic;
GSSetAcquisitionMode(m_hGevServer, acqMode);

// register server events
if (IsGevServer(m_hGevServer))
{
	GSRegisterEvent(m_hGevServer, SE_Connected, &Empty, NULL, m_nSERemoteEndpointConnectedEventID);
	GSRegisterEvent(m_hGevServer, SE_Disconnected, &Empty, NULL, m_nSERemoteEndpointDisconnectedEventID);
	GSRegisterEvent(m_hGevServer, SE_AcquisitionStart, &Empty, NULL, m_nSEAcquisitionStartEventID);
	GSRegisterEvent(m_hGevServer, SE_AcquisitionStop, &Empty, NULL, m_nSEAcquisitionStopEventID);
	GSRegisterEvent(m_hGevServer, SE_ImageSnapped, &Empty, NULL, m_nSENewImageEventID);
}

// add custom feature in category
AddGenICamFeatures();

// set custom version/id
nResult = GSSetInfoAsString(m_hGevServer, GSI_ServerUserVersion, "_C++-Example");
if (nResult < 0) throw std::exception();
nResult = GSSetInfoAsInteger(m_hGevServer, GSI_XMLVersionMajor, 1);
if (nResult < 0) throw std::exception();
nResult = GSSetInfoAsInteger(m_hGevServer, GSI_XMLVersionMinor, 0);
if (nResult < 0) throw std::exception();
nResult = GSSetInfoAsInteger(m_hGevServer, GSI_XMLVersionSubMinor, 0);
if (nResult < 0) throw std::exception();

// start server
std::vector<gsipv4> m_Interfaces;
GEVIFACELIST ifaceList = CreateInterfaceList();
size_t nIfaces = ILCount(ifaceList);
for (size_t nIndex = 0; nIndex < nIfaces; ++nIndex)
{
	// add IP to interfaces list
	gsipv4 nIP = 0;
	ILIPv4Address(ifaceList, nIndex, nIP);
	m_Interfaces.push_back(nIP);
}

gsipv4 nIP = m_Interfaces[2]; //for 172.29.54.161
nResult = GSStartIPv4(m_hGevServer, nIP);
if (nResult < 0)
	throw std::exception();

cout << "gev server started " << nResult << "\n";

while (true)
{
	
}

return 0;

```

}

---

<div class="post-metadata">

### Author: ![TStadler](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/tstadler/32/308_2.png) [@TStadler](https://forum.commonvisionblox.com/u/TStadler)
#### Post date: [May 25, 2018, 8:22am UTC](https://forum.commonvisionblox.com/t/how-to-start-c-gev-server-correctly-using-cvb-sdk-api/463/2 "2018-05-25T08:22:38Z")

</div>

Hi, could you post your whole project?  
This way it is easier for us to find the problem.

---

<div class="post-metadata">

### Author: ![zetazee85](https://avatars.discourse-cdn.com/v4/letter/z/b4bc9f/32.png) [@zetazee85](https://forum.commonvisionblox.com/u/zetazee85)
#### Post date: [May 25, 2018, 8:56am UTC](https://forum.commonvisionblox.com/t/how-to-start-c-gev-server-correctly-using-cvb-sdk-api/463/3 "2018-05-25T08:56:23Z")

</div>

Hi Tim,

I have uploaded the CPP (not working) and CSharp (working) zipped Visual Studio project.

CPP - GEVServerTestCpp.zip [Download Link](https://drive.google.com/open?id=1FO1-KlyJpNVD4Fxlf24P1dA-wL36BZUN)  
CSharp - CSGEVServerTest.zip [Download Link](https://drive.google.com/open?id=1pCPphgDcm_STXfDrJjqm3xUKmRoAiMlx)

Thank you for the assistance.

---

<div class="post-metadata">

### Author: ![TStadler](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/tstadler/32/308_2.png) [@TStadler](https://forum.commonvisionblox.com/u/TStadler)
#### Post date: [May 25, 2018, 9:04am UTC](https://forum.commonvisionblox.com/t/how-to-start-c-gev-server-correctly-using-cvb-sdk-api/463/4 "2018-05-25T09:04:24Z")

</div>

Hmm your C++ example is working just fine for me (only thing I did was update the Visual Studio Toolset).  
Could you try a different IP?

---

<div class="post-metadata">

### Author: ![zetazee85](https://avatars.discourse-cdn.com/v4/letter/z/b4bc9f/32.png) [@zetazee85](https://forum.commonvisionblox.com/u/zetazee85)
#### Post date: [May 26, 2018, 1:32am UTC](https://forum.commonvisionblox.com/t/how-to-start-c-gev-server-correctly-using-cvb-sdk-api/463/5 "2018-05-26T01:32:36Z")

</div>

Hi tim,

I am using Visual Studio 2013 to develop the attached C++ project. It can be compiled successfully and run with the GEV port 3956 utilized, but I am not able to discover the GEV virtual camera on the CVB management console.

You were able to do so for my C++ project?

---

<div class="post-metadata">

### Author: ![zetazee85](https://avatars.discourse-cdn.com/v4/letter/z/b4bc9f/32.png) [@zetazee85](https://forum.commonvisionblox.com/u/zetazee85)
#### Post date: [May 28, 2018, 2:49am UTC](https://forum.commonvisionblox.com/t/how-to-start-c-gev-server-correctly-using-cvb-sdk-api/463/6 "2018-05-28T02:49:38Z")

</div>

Hi Tim,

I managed to resolve the issue with my C++ application.  
When i changed the directory of the image emulator to the one on my desktop, then the application is working.

I suspect is to do with the permission access to the image emulator in the Program Files.
