|
|
Armond Sarkisian wrote: Can I zip up all four files and send it to you?
Before we do that, try this...I just connected to google.com - 3 different ip addresses returned
by DNS. step through this in the debugger. Notice I'm using ALL the info returned by getaddrinfo
to do the socket() and connect() calls. Does this all succeed for you?
char* ip = "google.com";
char* port = "80";
struct addrinfo aiHints;
struct addrinfo *aiList = NULL;
int retVal;
sockaddr addr;
memset(&aiHints, 0, sizeof(aiHints));
aiHints.ai_family = AF_INET;
aiHints.ai_socktype = SOCK_STREAM;
aiHints.ai_protocol = IPPROTO_TCP;
if ((retVal = getaddrinfo(ip, port, &aiHints, &aiList)) != 0)
{
printf("getaddrinfo() failed.\n");
}
else
{
int SockErr;
addrinfo *pAddrInfo = aiList;
while (pAddrInfo)
{
addr = *pAddrInfo->ai_addr;
SOCKET s = socket(pAddrInfo->ai_family, pAddrInfo->ai_socktype, pAddrInfo->ai_protocol);
if (s != INVALID_SOCKET)
{
if (SOCKET_ERROR == connect(s, &addr, sizeof(sockaddr)))
{
SockErr = WSAGetLastError();
}
closesocket(s);
}
else
{
SockErr = WSAGetLastError();
}
pAddrInfo = pAddrInfo->ai_next;
}
}
Same code without /pre tags...
char* ip = "google.com";
char* port = "80";
struct addrinfo aiHints;
struct addrinfo *aiList = NULL;
int retVal;
sockaddr addr;
memset(&aiHints, 0, sizeof(aiHints));
aiHints.ai_family = AF_INET;
aiHints.ai_socktype = SOCK_STREAM;
aiHints.ai_protocol = IPPROTO_TCP;
if ((retVal = getaddrinfo(ip, port, &aiHints, &aiList)) != 0)
{
printf("getaddrinfo() failed.\n");
}
else
{
int SockErr;
addrinfo *pAddrInfo = aiList;
while (pAddrInfo)
{
addr = *pAddrInfo->ai_addr;
SOCKET s = socket(pAddrInfo->ai_family, pAddrInfo->ai_socktype, pAddrInfo->ai_protocol);
if (s != INVALID_SOCKET)
{
if (SOCKET_ERROR == connect(s, &addr, sizeof(sockaddr)))
{
SockErr = WSAGetLastError();
}
closesocket(s);
}
else
{
SockErr = WSAGetLastError();
}
pAddrInfo = pAddrInfo->ai_next;
}
}
|
|
|
|
|
At the socket call I assume. WSAGetLastError() gives you what after that call?
|
|
|
|
|
|
|
OMG it took a long time to find the problem in your code
You owe me man I found 3 things - #1 was the tough one...
1) change (in sockets::socket_create()) Note parenthesis
//if( hSocket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ) != INVALID_SOCKET )
if( (hSocket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP )) != INVALID_SOCKET )
2) I added this to sockets::socket_end() (befor WSACleanup() call)
if (hSocket != INVALID_SOCKET)
{
closesocket(hSocket);
hSocket = INVALID_SOCKET;
}
3) change in (sockets::socket_end()) note comparison operator
//if( WSACleanup( ) != 0 ){ return( true ); }
if( WSACleanup( ) == 0 ){ return( true ); }
|
|
|
|
|
I've wasted an entire day over this, I can't find the information in the MSDN..
I'm using the VFW for video recording, I'm unable to enumerate the available video devices available and to select a specific device in code. The only method I found was to open the select device form (WM_CAP_DLG_VIDEOSOURCE) but I don't want any user interaction..
The MSDN states "..Connect and disconnect video and audio input devices dynamically" which is exactly what I want..
|
|
|
|
|
from the Platform SDK
Enumerating Installed Capture Drivers
The following example uses the capGetDriverDescription function to obtain the names and versions of the installed capture drivers.
char szDeviceName[80];
char szDeviceVersion[80];
for (wIndex = 0; wIndex < 10; wIndex++)
{
if (capGetDriverDescription (wIndex, szDeviceName,
sizeof (szDeviceName), szDeviceVersion,
sizeof (szDeviceVersion))
{
}
}
The index is what you're after. You'll need that for the WM_CAP_DRIVER_CONNECT message
Mark
|
|
|
|
|
That returns the driver name ('Microsoft WDM Image Capture (Win32)') not the device name ..
|
|
|
|
|
Yes That's all you get in VFW these days. WDM is a newer driver model so if you use
DirectShow (which supports WDM devices as well as legacy VFW drivers) then you'll see descriptive
names. With VFW you'll only see descriptive names for old devices that haven't moved to WDM.
Mark
|
|
|
|
|
Damn.. that really complicates things I was hoping to avoid DirectX.
It sounds quite absurd that you can open a device, but you can’t know its name.
|
|
|
|
|
tanffn_aj wrote: It sounds quite absurd that you can open a device, but you can’t know its name.
Yeah it's a pain. It makes it impossible to select a device either programmatically or presenting
the user with an intuitive list to choose from.
Microsoft hasn't deprecated VFW yet but the device manufacturers have moved on to WDM for their
drivers. Windows wraps those drivers so they can be used by VFW (that's the generic name you
get).
If only you had wasted a whole day in the DirectShow SDK instead....you'd probably have something
up and running (sorry - salt in the wound)
If you choose to (or have to) go the DirectShow route I'll help out if I can. The code samples
in the SDK work decent - it gets a little wordy with all the COM stuff but it's fairly
straight forward for common video capture tasks. Way more flexible than VFW as well.
Mark
|
|
|
|
|
Thanks for all the help so far Mark.
I’ll try to figure out DirectShow by my self for now. I Don’t want to ask questions that are too dumb.
|
|
|
|
|
I thought only unasked questions were too dumb...
BTW, the DirectShow SDK is in the Platform SDK, not the DirectX SDK if you didn't know already
Good luck!
Mark
|
|
|
|
|
I ended up using DSPACK (delphi). It went a lot faster then I expected, too bad I wasted a day on VFW..
|
|
|
|
|
Hello.
I'm trying to get connection to dBase file by using ODBC.
I'm trying to use code like this:
CDatabase cdb;<br />
cdb.OpenEx( _T("DBQ=F:\\database\\a.dbf;DefaultDir=F:\\database\\;DRIVER=Microsoft dBASE Driver (*.dbf);DriverId=533;MaxBufferSize=2048;PageTimeout=5;"));
But i get message: string F:\database\a.dbf is an invalid path. But this file exactly exists!!!
I'm using Visual Studio 2005. How should I solve the problem please?
|
|
|
|
|
Create a DSN in the ODBC Data Source Administrator. That way you can create the connection settings and test it right there.
led mike
|
|
|
|
|
It looks like the smiley-face-tongue-sticking-out may be the problem.
Otherwise, what led mike said.
Mark
|
|
|
|
|
It's just a guess, but do you need to put ODBC; before DBQ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
Only for test purposes try to change the location. I guess that file is in a network path.
Regards
David Leyva
|
|
|
|
|
|
No.
If I will create DSN, will my application run at the other computer?
|
|
|
|
|
Jackson86 wrote: ...the other computer?
What other computer?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I meant that, if i will create my DSN in ODBC Administrator in my computer, I sure that in another computer will be another DSN.
Bu t I've already done with my problem. I got ODBC connection,using connection string. I understood my error. It's necessary after "DBQ=" in connection string to write path of folder, not of file.
|
|
|
|
|
Jackson86 wrote: It's necessary after "DBQ=" in connection string to write path of folder, not of file.
That must be a dBase thing. I used the following for a DSN-less connection to an Access database:
"ODBC;Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\somefolder\\dataaccess\\ADO\\nwind.mdb;"
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|