I've got a modified version of the sockets example working, but I want to generate, or at least I expected to have some sort of error, when I tried to connect to a server that is not running.. I used the code
iSocket.Connect(iAddress, iStatus);
but no error was generated.. Urgent help is required... :-)
Hi memleak, I forgot to add that I checked the iStatus parameter and got KErrNone, even when the server I'm trying to connect to is down. I thought this was weird.. Help :-)
Hi memleak, I forgot to add that I checked the iStatus parameter and got KErrNone, even when the server I'm trying to connect to is down. I thought this was weird.. Help :-)
Here's the meat of the connection code, the message boxes is used for debugging on the device.. 6630. Essentially, I'm trying to connect over the internet using the vodafone internet IAP to a my local echo sever. I can connect Ok, but I still "seam" to be able t o connect even when my echo server is shut down? Thanks
// Start the Connection
iRConn.Start(prefs,iStatus);
ChangeStatus(ERConnStarting);
iTimer->After(KTimeOut);
SetActive();
}
}
void CExEngine::ConnectL(TUint32 aAddr)
{
// Initiate attempt to connect to a socket by IP address
if (iEngineStatus == ENotConnected)
{
// Open a TCP socket
User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp, iRConn));
// Set up address information
iAddress.SetPort(iPort);
iAddress.SetAddress(aAddr);
void CExEngine::RunL()
{
// Active object request complete handler.
// iEngineStatus flags what request was made, so its
// completion can be handled appropriately
iTimer->Cancel(); // Cancel TimeOut timer before completion
switch(iEngineStatus)
{
case ERConnStarting:
// need to look up name using dns
// Initiate DNS
if (iStatus == KErrNone)
{
User::LeaveIfError(iResolver.Open(iSocketServ, KAfInet, KProtocolInetTcp, iRConn));
// DNS request for name resolution
iResolver.GetByName(iServerName, iNameEntry, iStatus);
ChangeStatus(ELookingUp);
// Request time out
iTimer->After(KTimeOut);
SetActive();
}
else
{
MsgBox(_L("CONNECTING-ENTERED"));
if (iStatus == KErrNone)
// Connection completed successfully
{
MsgBox(_L("CONNECTING-OK"));
ChangeStatus(EConnected);
// Get the time
Read();
}
else
{
MsgBox(_L("COnnection Failed"));
ChangeStatus(ENotConnected);
Cancel();
ReportErrorL(EConnectionFailed, iStatus.Int());
}
break;
case EConnected:
case EReading:
{
MsgBox(_L("READING::CONNECTED"));
I can't see how the port number and IP address affects not getting an error code if the server is not running. Have you had this happen to you before. From my knowledge of sockets, even if I tried to write to it, I should get an i/o exception, I don't even get this, Please educate :-)
Has anyone tried using the symbian Tcp connection to blocked port. i.e iSocket.connect(iStatus); Make the connection to a real IP address but to a blocked port . Do you get an error ? I don't seam to one. Help :-)
Has anyone tried using the symbian Tcp connection to blocked port. i.e iSocket.connect(iStatus); and using Rconnection. Make the connection to a real IP address but to a blocked port . Do you get an error ? I don't seem to one. Help :-)
Socket Connect returns KErrNone even if server is not running
2005-05-14, 01:44#12
I am also facing the same problem. I have defined two servers- primary and secondary. In case my app fails to connect to primary server, it can connect to secondary. But the problem is that anytime I call iSocket.Connect(), it rtuens immediately (I mean RunL is called immediately) with iStataus as KErrNone. It always return me KErrNone even if my server is not running. The strange thing is that it even doesn't time out. So my app just keep waiting for connect to finish.
As per documentation the Connect should return with some error in RunL, but in reality it doesn't. Did you find some soultion for your problem.
The symbian rsocket.connect() API does not appear to inform yu about a succesful connection, instead, i believe it informs yu that an atempt at a connection has sucesfully started. I used a work around to solve my problem. The application I was working on was designed to handle enquire response data between the client and the server. So after I get the Kerrnon, I send an enqire data packet and if don't get a response within say 10 secs, I assume the connection is down.