Discussion Board
Sending data using Sockets
2004-10-06, 07:44
#1
Super Contributor
What is the process of sending data using Sockets .
I have made a connection using Socket.Connect()
Now what to do after this ..
Becase when i do something like
if(iRunState==ESocketConnected)
{
iSocket.Write(aDesc,iStatus);
SetActive();
iRunState=ECommandSent;
}
The program crashes......
Nokia Developer Expert
what is the error note shown during the crash ?
Also is the aDesc a member variable of the class ?, it should really be, since othervise it could go out-of-scope during the write process.
yucca
Super Contributor
oho ..
It is not the member of the class .
I m just passing it as a perimeter in a function .
Okie .. i wil make it a member of the class now .
Super Contributor
Hi Yucca now i have made it a member of the class and this is the latest situation ....
this is the code ..........
Code:
//in Connect Function
// Connect to the server, asynchronously
iSocket.Connect( iInetAddr, iStatus );
SetActive();
//in RunL()
Code:
void CConnection::RunL()
{
switch ( iRunState )
{
case ESocketConnected:
//User::LeaveIfError(iStatus.Int());// leave on bad return code
if(iStatus==KErrNone)
{
iRunState=ESocketConnected;
_LIT(KSocketConnnectedMessage, "Socket Connected");
CEikonEnv::Static()->AlertWin(KSocketConnnectedMessage);
}
break;
and in Send data ffunction
Code:
void CConnection::Send(const TDesC8& aDesc)
{
iSndBuffer=aDesc;
if(iRunState==ESocketConnected)
{
iSocket.Write(iSndBuffer,iStatus);
SetActive(); .\\Leaves here .......
iRunState=ECommandSent;
}
}
also when i reach the line setActive the connection has not been made.
As i m testing it on a java server where it shows when connected.
But when i m checking iRunState==ESocketConnected
how is it possible that without making the connection it executes the "iSocket.Write(iSndBuffer,iStatus);"
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules