Click here to Skip to main content
15,910,123 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: ThreadPool not executing queued jobs Pin
led mike19-Dec-08 7:15
led mike19-Dec-08 7:15 
GeneralRe: ThreadPool not executing queued jobs Pin
Helfdane21-Dec-08 23:27
Helfdane21-Dec-08 23:27 
AnswerRe: ThreadPool not executing queued jobs Pin
Dave Kreskowiak18-Dec-08 8:21
mveDave Kreskowiak18-Dec-08 8:21 
GeneralRe: ThreadPool not executing queued jobs Pin
led mike18-Dec-08 8:35
led mike18-Dec-08 8:35 
GeneralRe: ThreadPool not executing queued jobs Pin
Dave Kreskowiak18-Dec-08 9:03
mveDave Kreskowiak18-Dec-08 9:03 
GeneralRe: ThreadPool not executing queued jobs Pin
led mike18-Dec-08 9:05
led mike18-Dec-08 9:05 
QuestionRoaming AND local settings ? Pin
koosquarto17-Dec-08 23:23
koosquarto17-Dec-08 23:23 
Questionwinsock error 10014 Plz help Pin
abhiabstract16-Dec-08 14:22
abhiabstract16-Dec-08 14:22 
Hi I am trying to build a bluetooth application. I am trying to connect my laptop to my phone. This is the code i am using. I dont know why i keep getting this winsock error 10014. I looked into MSDN which says

"Bad address.

The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a sockaddr structure, is smaller than the sizeof(sockaddr)."

I am not sure how to check the buffer and how can i find out whats wrong. Please help me i am stuck!!!


///// My code/////////////////////

#include "stdafx.h"
#include <initguid.h>
#include <winsock2.h>
#include <ws2bth.h>
#include <stdio.h>
DEFINE_GUID(OBEXFileTransfer, 0x00001106, 0x0000, 0x1000, 0x80,0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb);
int SDPGetPort( const char *addr, LPGUID guid )
{
int port = 0;
HANDLE h;
WSAQUERYSET *qs;
DWORD flags = 0;
DWORD qs_len;
bool done;
qs_len = sizeof(WSAQUERYSET);
qs = (WSAQUERYSET*) malloc( qs_len );
ZeroMemory( qs, qs_len );
qs->dwSize = sizeof(WSAQUERYSET);
qs->lpServiceClassId = guid;
qs->dwNameSpace = NS_BTH;
qs->dwNumberOfCsAddrs = 0;
qs->lpszContext = (LPSTR) addr;
flags = LUP_FLUSHCACHE | LUP_RETURN_ADDR;
wprintf (L"GUID ,%d %d",&qs_len,sizeof(WSAQUERYSET) );
if( SOCKET_ERROR == WSALookupServiceBegin( qs, flags, &h )) {
wprintf (L"Socket create, error 1 -%d\n", WSAGetLastError ());
//ExitProcess(2);
}
done = false;
while ( ! done ) {
if( SOCKET_ERROR == WSALookupServiceNext( h, flags, &qs_len, qs ) ) {

wprintf (L"Socket create, error 2 -%d\n", WSAGetLastError ());
int error = WSAGetLastError();
if( error == WSAEFAULT ) {
free(qs);
qs = (WSAQUERYSET*) malloc( qs_len );
} else if (error == WSA_E_NO_MORE ) {
done = true;
} else {
wprintf (L"Socket create, error 3- %d\n", WSAGetLastError ());
//ExitProcess(2);
}
} else {
port =
((SOCKADDR_BTH*)qs->lpcsaBuffer->RemoteAddr.lpSockaddr)->port;
}
}
free(qs);
WSALookupServiceEnd( h );
return port;
}

int _tmain(int argc, _TCHAR* argv[])
{
SOCKET sock;
SOCKADDR_BTH sa = { 0 };
int sa_len = sizeof(sa);
// initialize windows sockets
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD( 2, 0 );
if( WSAStartup( wVersionRequested, &wsaData ) != 0 ) {
ExitProcess(2);
}
// parse the specified Bluetooth address
LPSTR abhi = "00:1d:fd:8e:21:8d";
int abhisize = sizeof (abhi);
if( abhisize < 2 ) {
fprintf(stderr, "usage: rfcomm-client <addr>\n"
"\n addr must be in the form (XX:XX:XX:XX:XX:XX)");

//ExitProcess(2);
}
if( SOCKET_ERROR == WSAStringToAddress( abhi, AF_BTH,
NULL, (LPSOCKADDR) &sa, &sa_len ) ) {
wprintf (L"String to address %d\n", WSAGetLastError ());

//ExitProcess(2);
}
// query it for the right port
// create the socket
sock = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
if( SOCKET_ERROR == sock ) {
wprintf (L"Socket create, error %d\n", WSAGetLastError ());

//ExitProcess(2);
}
// fill in the rest of the SOCKADDR_BTH struct
sa.port = SDPGetPort(abhi, (LPGUID) &OBEXFileTransfer);

//if( sa.port == 0 ) {
//ExitProcess(2);
//}
if( SOCKET_ERROR == connect( sock, (LPSOCKADDR) &sa, sa_len ) ) {
wprintf (L"Socket connect, error %d\n", WSAGetLastError ());

//ExitProcess(2);
}
send( sock, "hello!", 6, 0 );
closesocket(sock);

Sleep(10000);

return 0;
}
AnswerRe: winsock error 10014 Plz help Pin
Dave Kreskowiak16-Dec-08 17:35
mveDave Kreskowiak16-Dec-08 17:35 
AnswerRe: winsock error 10014 Plz help Pin
Paul Conrad17-Dec-08 5:31
professionalPaul Conrad17-Dec-08 5:31 
QuestionCS file invocation at the end of task? Pin
NetQuestions16-Dec-08 6:52
NetQuestions16-Dec-08 6:52 
AnswerRe: CS file invocation at the end of task? Pin
Dave Kreskowiak16-Dec-08 8:58
mveDave Kreskowiak16-Dec-08 8:58 
QuestionFree or opensource versioning tool for Visual Studio 2008 Pin
Azghar Hussain16-Dec-08 3:20
professionalAzghar Hussain16-Dec-08 3:20 
AnswerRe: Free or opensource versioning tool for Visual Studio 2008 Pin
AndrewSmith16-Dec-08 6:10
AndrewSmith16-Dec-08 6:10 
GeneralRe: Free or opensource versioning tool for Visual Studio 2008 Pin
Azghar Hussain16-Dec-08 17:23
professionalAzghar Hussain16-Dec-08 17:23 
GeneralRe: Free or opensource versioning tool for Visual Studio 2008 Pin
Simon P Stevens16-Dec-08 21:39
Simon P Stevens16-Dec-08 21:39 
QuestionAdding button at runtime in MDI Pin
NetQuestions16-Dec-08 2:02
NetQuestions16-Dec-08 2:02 
AnswerRe: Adding button at runtime in MDI Pin
Simon P Stevens16-Dec-08 2:58
Simon P Stevens16-Dec-08 2:58 
GeneralRe: Adding button at runtime in MDI Pin
NetQuestions16-Dec-08 6:59
NetQuestions16-Dec-08 6:59 
GeneralRe: Adding button at runtime in MDI Pin
Dave Kreskowiak16-Dec-08 8:46
mveDave Kreskowiak16-Dec-08 8:46 
GeneralRe: Adding button at runtime in MDI Pin
Simon P Stevens16-Dec-08 21:35
Simon P Stevens16-Dec-08 21:35 
JokeRe: Adding button at runtime in MDI Pin
Mycroft Holmes16-Dec-08 22:00
professionalMycroft Holmes16-Dec-08 22:00 
GeneralRe: Adding button at runtime in MDI Pin
Simon P Stevens16-Dec-08 23:34
Simon P Stevens16-Dec-08 23:34 
JokeRe: Adding button at runtime in MDI Pin
Thomas Stockwell17-Dec-08 5:29
professionalThomas Stockwell17-Dec-08 5:29 
JokeRe: Adding button at runtime in MDI Pin
Expert Coming17-Dec-08 18:40
Expert Coming17-Dec-08 18:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.