Hi,

I am using Symbian 6.0 SDK for Nokia 9200 series on Windows 2000 platform. I configured the dialup networking in the EPOC emulator using a regular modem connected to my system serial port.

Configuration Settings:
Internet access: (Control Panel)
2182222
Preferred Connection > dinesh
If idle, stay online >for 5 minutes
Ask before connecting > No
Phone number > 2182222
Password prompt > No
Username > dinesh
Password > ******
Confirm password > ******

Emulator Internet Access: (Emulator Internet Access)
Profile: dinesh
Profile type > Analog modem
Port > COM2
Data rate > 57600
Connection > Cable
Auto retrieve IP address > Yes
Auto retrieve DNS address > Yes

Emulator is working properly and I am able to browse the web using WWW
application that come with the emulator. Emulator dials out and connects with my ISP. So I am able to browse all sites. Here starts the problem :-).

I am developing a small network client application(console/commandline
application) written in C, targeted to EPOC exe, is complied successfully for WINS. The exe is resided in Epoc32\Release\wins\udeb directory. When I tried to run this application by double-clicking on it(on the exe file), it started running. The application created a socket and blocked on connect()(found this when debugging using VC++). The emulator didn't even tried to dialout for establish a internet connection.

Is it possible to write a .exe application(console application) to implement a simple network client (such as WWW, FTP,etc)?

Is this the correct way to execute a EPOC exe(console application) on the emulator?

Whether a exe(console application) have access to dialup networking in order to dialout and connect to the internet?

Is there any way to execute an exe (console application) from the EPOC
emulator (from Filemanager??) like running a GUI application (.app) from EPOC Extras window?

Can I call an exe application inside the GUI (.app) application?

All answers to my questions are greatly appreciated.

Herewith i placed my source files. Please point out where am I going wrong.

Thanks,
Dinesh.

My source files: (I am able to compile and link successfully)

// ********************************************************
//Webclient.cpp

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "CommonFramework.h"
#define MAXRECVBUFFSIZE 2048

int getmypage(void);

// do the example
LOCAL_C void doExampleL(){
//_LIT(KHelloWorldText,"Hello world!\n"
//console->Printf(KHelloWorldText);
getmypage();
}

int getmypage(void){
char serverIP[20];
unsigned short portNo = 80;
int mysocket;

strcpy(serverIP, "203.197.156.175"
if ((mysocket = socket(AF_INET, SOCK_STREAM, 0)) < 0)
return 1;
struct sockaddr_in serverSockaddr;
serverSockaddr.sin_family = AF_INET;
serverSockaddr.sin_port = htons(portNo);
serverSockaddr.sin_addr.s_addr = inet_addr(serverIP);
int serverSockaddrLen = sizeof(struct sockaddr_in);

if ((connect(mysocket, (struct sockaddr *)&serverSockaddr,
serverSockaddrLen)) != 0)
return 1;

char reqhead[500], templ[500];
memset(templ, 0, sizeof(reqhead));
memset(reqhead, 0, sizeof(reqhead));
strcpy(templ, "GET /index.html HTTP/1.1\r\n"
strcat(templ, "Accept: image/gif, image/jpeg, */*\r\n"
strcat(templ, "Accept-Language: en-us\r\n"
strcat(templ, "Accept-Encoding: gzip, deflate\r\n"
strcat(templ, "User-Agent: Webclient\r\n"
strcat(templ, "Host: %s\r\n"
strcat(templ, "Connection: Keep-Alive\r\n\r\n"
sprintf(reqhead, templ, serverIP);
printf("%s", reqhead);

unsigned int noofbytes = send(mysocket, reqhead, strlen(reqhead), 0);
if (noofbytes != strlen(reqhead))
return 1;
else
printf("sent %d bytes\n", noofbytes);

char recvBuf[MAXRECVBUFFSIZE];
char resphead[500];
char crlf[5], crlf2[10], cntlentag[20], cntlenstr[10];
int NumOfChars, cntlen;
int size=0;
char *index, *eindex;
memset(resphead, 0, sizeof(resphead));
memset(cntlenstr, 0, sizeof(cntlenstr));
strcpy(crlf, "\r\n"
strcpy(crlf2, "\r\n\r\n"
strcpy(cntlentag, "Content-Length: "

//receving and parsing http header
while(true){
NumOfChars = recv(mysocket, resphead+size, sizeof(char), 0);
if (NumOfChars <= 0)
return 1;
size += NumOfChars;
if (strcmp(crlf2, resphead+size-strlen(crlf2)) == 0)
break;
if (size > sizeof(reqhead))
return 1;
}
printf("%s", resphead);
if (strstr(resphead, "200 OK&quot == NULL)
return 1;
if ((index = strstr(resphead, cntlentag)) == NULL)
return 1;
index = index + strlen(cntlentag);
eindex = strstr(index, crlf);

strncpy(cntlenstr, index, eindex-index);
cntlenstr[eindex-index] = 0;
cntlen = atoi(cntlenstr);
if (cntlen >= MAXRECVBUFFSIZE)
return 1;
// receiving data
size = 0;
memset(recvBuf, 0, sizeof(recvBuf));
while (size <= cntlen){
NumOfChars = recv(mysocket, recvBuf+size, cntlen, 0);
if (NumOfChars < 0)
return 1;
size = size + NumOfChars;
if ((NumOfChars == 0) | (cntlen == size))
break;
}
printf("%d", strlen(recvBuf));
return 0;
}


// ********************************************************

// CommonFramework.h
// Copyright (c) 2000 Symbian Ltd. All rights reserved.


#ifndef __CommonFramework_H
#define __CommonFramework_H

#include <e32base.h>
#include <e32cons.h>

_LIT(KTxtEPOC32EX,"Webclient"
_LIT(KTxtExampleCode,"Running Web Client"
_LIT(KFormatFailed,"failed: leave code=%d"
_LIT(KTxtOK,"ok"
_LIT(KTxtPressAnyKey," [press any key]"

// public
LOCAL_D CConsoleBase* console; // write all your messages to this
LOCAL_C void doExampleL(); // code this function for the real example

// private
LOCAL_C void callExampleL(); // initialize with cleanup stack, then do
example

GLDEF_C TInt E32Main() // main function called by E32
{
__UHEAP_MARK;
CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
TRAPD(error,callExampleL()); // more initialization, then do example
__ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
delete cleanup; // destroy clean-up stack
__UHEAP_MARKEND;
return 0; // and return
}

LOCAL_C void callExampleL() // initialize and call example code under
cleanup stack
{

console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen)
);
CleanupStack::PushL(console);
TRAPD(error,doExampleL()); // perform example function
if (error)
console->Printf(KFormatFailed, error);
else
console->Printf(KTxtOK);
console->Printf(KTxtPressAnyKey);
console->Getch(); // get and ignore character
CleanupStack::PopAndDestroy(); // close console
}

#endif
// CommonFramework.h
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.


#ifndef __CommonFramework_H
#define __CommonFramework_H

#include <e32base.h>
#include <e32cons.h>

_LIT(KTxtEPOC32EX,"Webclient"
_LIT(KTxtExampleCode,"Running Web Client"
_LIT(KFormatFailed,"failed: leave code=%d"
_LIT(KTxtOK,"ok"
_LIT(KTxtPressAnyKey," [press any key]"

// public
LOCAL_D CConsoleBase* console; // write all your messages to this
LOCAL_C void doExampleL(); // code this function for the real example

// private
LOCAL_C void callExampleL(); // initialize with cleanup stack, then do
example

GLDEF_C TInt E32Main() // main function called by E32
{
__UHEAP_MARK;
CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
TRAPD(error,callExampleL()); // more initialization, then do example
__ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
delete cleanup; // destroy clean-up stack
__UHEAP_MARKEND;
return 0; // and return
}

LOCAL_C void callExampleL() // initialize and call example code under
cleanup stack
{

console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen)
);
CleanupStack::PushL(console);
TRAPD(error,doExampleL()); // perform example function
if (error)
console->Printf(KFormatFailed, error);
else
console->Printf(KTxtOK);
console->Printf(KTxtPressAnyKey);
console->Getch(); // get and ignore character
CleanupStack::PopAndDestroy(); // close console
}

#endif
// CommonFramework.h
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.


#ifndef __CommonFramework_H
#define __CommonFramework_H

#include <e32base.h>
#include <e32cons.h>

_LIT(KTxtEPOC32EX,"Webclient"
_LIT(KTxtExampleCode,"Running Web Client"
_LIT(KFormatFailed,"failed: leave code=%d"
_LIT(KTxtOK,"ok"
_LIT(KTxtPressAnyKey," [press any key]"

// public
LOCAL_D CConsoleBase* console; // write all your messages to this
LOCAL_C void doExampleL(); // code this function for the real example

// private
LOCAL_C void callExampleL(); // initialize with cleanup stack, then do
example

GLDEF_C TInt E32Main() // main function called by E32
{
__UHEAP_MARK;
CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
TRAPD(error,callExampleL()); // more initialization, then do example
__ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
delete cleanup; // destroy clean-up stack
__UHEAP_MARKEND;
return 0; // and return
}

LOCAL_C void callExampleL() // initialize and call example code under
cleanup stack
{

console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen)
);
CleanupStack::PushL(console);
TRAPD(error,doExampleL()); // perform example function
if (error)
console->Printf(KFormatFailed, error);
else
console->Printf(KTxtOK);
console->Printf(KTxtPressAnyKey);
console->Getch(); // get and ignore character
CleanupStack::PopAndDestroy(); // close console
}

#endif

// ********************************************************

// Webclient.mmp

// using relative paths for sourcepath and user includes
TARGET Webclient.exe
TARGETTYPE exe
UID 0

SOURCEPATH .
SOURCE Webclient.cpp

USERINCLUDE .
USERINCLUDE ..\CommonFramework

SYSTEMINCLUDE \Epoc32\include
SYSTEMINCLUDE \Epoc32\include\libc
LIBRARY euser.lib estlib.lib

// ********************************************************
// BLD.INF
// Component description file
//

PRJ_MMPFILES

Webclient.mmp

// ********************************************************