Network problems with the emulator integrated in VS2005 and an error in a piece of code that I can't understand
- From: Christian <voodoo81people@xxxxxxxxx>
- Date: Thu, 31 Jan 2008 10:43:54 -0800 (PST)
Hi everybody
I have some questions about the way you experienced programmers debug
your Windows CE based application. First of all I use Vista,Visual
Studio 2005 and Windows Mobile Device Center (ActiveSync for Vista).
1) How can I share my network connection between my PC and the
emulator integrated in Visual Studio? If I go in the Emulator to File
Configure > Network and I try to flag "enable NE2000 netword adapterand bind to",I receive an error that invites me to download Virtual PC
2007. After having installed this software, I receive the error :"No
VPC network adapters enumerated or no host network adapter with
provided MAC address found". So I can't surf the net. I've read all
the guide but I haven't understood how can I reach my goal. What's the
problem?
2) How do you debug your application? For example printf calls can't
be displayed in the Emulator nor in Visual Studio. how do you debug
your apps?
3) Do you know any site,code examples or updated book that deal with
socket programming on Pocket PC?
4) I'm trying to learn by examples so I have this code:
WSADATA wsaData;
memset(&wsaData, 0, sizeof(WSADATA));
if(WSAStartup(MAKEWORD(1,1), &wsaData) != 0){
return 1;
}
// Create a connection-oriented socket
SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// Check to see if we have a valid socket
if(s == INVALID_SOCKET) {
int iSocketError = WSAGetLastError();
return 2;
}
SOCKADDR_IN sListener;
memset(&sListener, 0, sizeof(SOCKADDR_IN));
// Setup the port to bind on
sListener.sin_family = AF_INET;
sListener.sin_port = htons(8080);
sListener.sin_addr.s_addr = htonl(INADDR_ANY);
// Bind to the socket
if(bind(s, (SOCKADDR *)&sListener, sizeof(sListener)) ==
SOCKET_ERROR) {
int iSocketError = WSAGetLastError();
return 3;
}
// Listen for incoming connections
if(listen(s, SOMAXCONN) == SOCKET_ERROR) {
int iSocketError = WSAGetLastError();
return 4;
}
// Wait for a connection
SOCKADDR_IN sIncomingAddr;
memset(&sIncomingAddr, 0, sizeof(SOCKADDR_IN));
int iAddrLen = sizeof(SOCKADDR_IN);
SOCKET sIncomingSocket = accept(s, (SOCKADDR *) &sIncomingAddr,
&iAddrLen);
if(sIncomingSocket == SOCKET_ERROR) {
int iSocketError = WSAGetLastError();
return 5;
}
// We have an incoming socket request
char cResponseBuffer[1024] = "";
int nBytesReceived = 0;
// Get a basic request. In reality, we would want to check
// the HTTP request to see if it's valid, but let's just
// send a simple response.
nBytesReceived = recv(sIncomingSocket, &cResponseBuffer[0], 1024, 0);
if(nBytesReceived == SOCKET_ERROR) {
int iSocketError = WSAGetLastError();
return iSocketError;
}
// Send out a response
char cBuffer[1024] = "";
int nBytesSent = 0;
int nBytesIndex = 0;
// Setup the buffer to send
sprintf(cBuffer, "HTTP/1.0 200 OK\r\n\r\nTest Response\r\n\r\n");
int nBytesLeft = strlen(cBuffer);
// Send the entire buffer
while(nBytesLeft > 0) {
nBytesSent = send(sIncomingSocket, &cBuffer[nBytesIndex],
nBytesLeft, 0);
if(nBytesSent == SOCKET_ERROR)
break;
// See how many bytes are left. If we still need to send, loop
nBytesLeft -= nBytesSent;
nBytesIndex += nBytesSent;
}
// Close the sockets
closesocket(sIncomingSocket);
closesocket(s);
WSACleanup();
return 0;
}
then I open Pocket Internet Explorer and I type "http://localhost:
8080". the program terminates with code 10054 ("The program
'[2da34576] moduleServer.exe' has exited with code 10054 (0x2746).").
The error happens at this point I suppose: nBytesReceived =
recv(sIncomingSocket, &cResponseBuffer[0], 10000, 0).I found that this
error code is defined in winsock2.h as #define WSAECONNRESET
(WSABASEERR+54) defined here[1] as "The virtual circuit was reset by
the remote side executing a hard or abortive close. The application
should close the socket because it is no longer usable." Is it maybe
related to the fact I haven't connection for the emulator? What's the
problem?
Thanks in advance,I'm very sorry to posts easy questions for you but
I'm really new to all this matter and I HAVE TO do a probject so thank
you for any help given to me :)
[1]: http://msdn2.microsoft.com/en-us/library/aa922642.aspx
.
- Follow-Ups:
- Prev by Date: Re: Broadcom/Widcomm Bluetooth Device Inquiry Taking Too Long
- Next by Date: Re: Network problems with the emulator integrated in VS2005 and an error in a piece of code that I can't understand
- Previous by thread: Widcomm BT threadsafe?
- Next by thread: Re: Network problems with the emulator integrated in VS2005 and an error in a piece of code that I can't understand
- Index(es):
Relevant Pages
|
Loading