|
Presumably you are using a byte lookup rather than a mask operation.
You can try indexing from end to end and then using two indexes one for the first row (say position X) and then one one for the second (X+1024). However that would then require an if test each time to skip the second row once you reached 1024.
|
|
|
|
|
hi
I'm programming a c++ client to receive packets from a server (UDP broadcast). This is a hardware switch (One direction only) system so I have no information regarding the senders address or any other info. It all compiles and binds OK but no packets received.
WSAStartup(0x0101, &_wsaData);
memset((char *)&_sockaddr, 0, sizeof(_sockaddr));
_sockaddr.sin_addr.s_addr = _nAdapterIp;
_sockaddr.sin_family = _nadressFam;
_sockaddr.sin_port = _usPort;
_socket = socket(_nadressFam, SOCK_DGRAM, 0);
char broadcast='1';
setsockopt(_socket, SOL_SOCKET, SO_BROADCAST, &broadcast ,sizeof(broadcast));
bind(_socket, (sockaddr*) & _sockaddr, sizeof (_sockaddr));
char* recvbuf = new char[_nPacketSize + 1];
int nSize = recv(_socket, recvbuf, _nPacketSize + 1, 0);
Any ideas? Thanks,
|
|
|
|
|
One important thing to do is look at the return codes for the methods that you are calling and your socket constructor, most times they will give you a clue about what is wrong. Also, what are values _nAdapterIp, _nadressFam, and _usPort? Could you be suffering from endian type issues?
|
|
|
|
|
sorry abut that, I shorten it so the code will be clear....
The actual code has the tests:
if (WSAStartup(0x0101, &_wsaData) != 0)
{
fprintf(stderr, "Could not open Windows connection.\n");
exit(0);
}
char broadcast= (char)1;
if (setsockopt(_socket, SOL_SOCKET, SO_BROADCAST, &broadcast ,sizeof(broadcast)) != 0)
{
fprintf(stderr, "Could not set socket options.\n");
WSACleanup();
exit(0);
}
etc....
|
|
|
|
|
arishri wrote: _socket = socket(_nadressFam, SOCK_DGRAM, 0); //Gave it a try with (17) - UDP for the 3 rd parameter - not working
How could you tell it wasn't working? I assume IPPROTO_UDP equates to '17'. When your application is running, and you go to DOS prompt and do a "netstat -a" do you see your socket with the proper port listed?
|
|
|
|
|
_socket = socket(_nadressFam, SOCK_DGRAM, 17);
_socket1 = socket(_nadressFam, SOCK_DGRAM, 17);
if ((_socket == INVALID_SOCKET) || (_socket1 == INVALID_SOCKET))
{
fprintf(stderr, "Could not create socket.\n");
WSACleanup();
exit(0);
}
|
|
|
|
|
Stick with one socket for now. If it still fails, call WSAGetLastError() and see what the error is.
|
|
|
|
|
int nSize = recv(_socket, recvbuf,_nPacketSize + 1, 0);
Get no packages here....
|
|
|
|
|
I couldn't be firewall related, could it?
|
|
|
|
|
<pre Lang="turbo c">
#include<studio.m>
main()
{
char m;
int p;
float n;
scanf ("%s%d%f",&m,&p,&n);
} </pre>
|
|
|
|
|
Hi everyone
The output of this code is 10,
I want to know why **q prints 10?
int x,*p,**q;
x=10;
p=&x
q=&p;
cout<<**q;
|
|
|
|
|
p points to x, which is assigned 10.
q points to p, which points to x.
*q returns p. Now you need to dereference that result to get to x. With parenthesis, you get: *(*q) == *p
|
|
|
|
|
Hello sound and video gurus. I am trying to capture my integrated web cam using Media Foundation APIs. I could not figure out the following couple of points.
1 - Difference between RAW video and uncompressed video
2 - Video format for RAW video (like PCM for RAW audio, MFVideoFormat_Base perhaps?)
I am using the following code to capture and store data onto my hard disk (a lot of code is ommited for clarity). I am saving on 100 samples but it stores 267+ hours of data. Here it is
BOOL CMyClass::StartRecording()
{
HRESULT hResult;
dwActualStreamIndex = 0;
m_bFirstSample = TRUE;
m_llBaseTime = 0, m_llTimeStamp = 0;
IMFSample* pSample = NULL;
IMFMediaBuffer* pMediaBuffer = NULL;
BYTE* pData = NULL;
BOOL bResult = InitCamera(); if(!bResult) return FALSE;
hResult = m_pReader->ReadSample((DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, &dwActualStreamIndex, &dwStreamsFlags, &m_llTimeStamp, &pSample);
if(FAILED(hResult)) return FALSE;
hResult = m_pReader->ReadSample((DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, &dwActualStreamIndex, &dwStreamsFlags, &m_llTimeStamp, &pSample);
if(FAILED(hResult)) return FALSE;
for (DWORD i = 0; i < 100; ++i)
{
hResult = m_pWriter->WriteSample(0, pSample);
if(FAILED(hResult)) return FALSE;
unsigned int c=0;
hResult=pSample->GetBufferCount((DWORD*)&c);
if(FAILED(hResult))MessageBox(NULL, "err","get buffer count", MB_OK);
IMFMediaBuffer* buffer=NULL;
hResult=pSample->GetBufferByIndex(0,&buffer);
if(FAILED(hResult))MessageBox(NULL, "err","GetBufferByIndex", MB_OK);
unsigned int sz=0;
hResult=buffer->GetCurrentLength((DWORD*)&sz);
if(FAILED(hResult))MessageBox(NULL, "err","GetCurrentLength", MB_OK);
unsigned char* data=NULL;
unsigned int validSize=0;
hResult=buffer->Lock((BYTE**)&data,NULL,(DWORD*)&validSize);
if(FAILED(hResult))MessageBox(NULL, "err","Lock", MB_OK);
hResult=buffer->Unlock();
if(FAILED(hResult))MessageBox(NULL, "err","Unlock", MB_OK);
hResult = m_pReader->ReadSample((DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, &dwActualStreamIndex, &dwStreamsFlags, &m_llTimeStamp, &pSample);
if(FAILED(hResult)) return FALSE;
}
return TRUE;
}
Thanks for any pointers.
modified 9-Dec-13 7:57am.
|
|
|
|
|
I find some application can show a number in the shutcut in the desktop , but I cannot find which windows api can do it. Is there anyone know it?
|
|
|
|
|
What do you mean by "show a number in the shutcut in the desktop"?
Veni, vidi, abiit domum
|
|
|
|
|
Do you mean something like "Microsoft Word (2)"?
|
|
|
|
|
No, this is changed the shortcut name. I means that display a number in the icon of the shortcut.
|
|
|
|
|
So overlay an image of a number on top of an existing icon?
|
|
|
|
|
Yes, I donot know which windows api can do it.
|
|
|
|
|
|
The problem is that a host could have lots of network interfaces, and an interface could be bound to more than one IP address. And to top that, not all IP addresses will be reachable from off the machine. Some could be virtual devices, and others could be private network IP addresses.
How do i know my local ip address which is currently reachable from outside network?
|
|
|
|
|
Is this something to do with C++?
Veni, vidi, abiit domum
|
|
|
|
|
Yes, i am looking for a C Program for this...
|
|
|
|
|
|
|