I am newer with symbian,I want to connect symbian OS with PC(winXP) by socket,the symbian OS as client,PC as the Server. I can create the connect between them,but I can't send/receive data between them normally.
On first and second session the client and the server are correct,but on the third session the server can send data correctly,but the client(symbian os) can't send data to server and the connection is OK. Anyone know the reason? I worry about it all the times. Here my part source code are:
The Client:
iStatus = KRequestPending;
iSocket.Connect(iAddress, iStatus);
User::WaitForRequest(iStatus);
if (iStatus.Int() ==KErrNone)
{
TSockXfrLength iDummyLength;
TInt recvSize;
for( ; ; )
{
//iStatus = KRequestPending;
//iSocket.Connect(iAddress, iStatus);
//User::WaitForRequest(iStatus);
recvSize = 0;
iStatus = KRequestPending;
iSocket.RecvOneOrMore(recvBuf, 0, iStatus, iDummyLength);
User::WaitForRequest(iStatus);
recvSize = iDummyLength();
if(iStatus.Int() ==KErrNone)
{
if(recvSize !=0)
{
//LaunchAppL();
//LaunchPyScriptL(recvBuf);
recvBuf.FillZ();
recvSize =0;
iStatus = KRequestPending;
iSocket.Write(writeBuf,iStatus);
User::WaitForRequest(iStatus);
}
else
{
break;
}
}
else
{
break;
}
}
}
The Server(winsocket):
int i=0, length = 0;
while(!done)
{
memset(buff1,0,sizeof(buff1));
if(i == 4)
{
done = true;
}
for(i=0; i<4; i++)
{
strcpy(buff1, "test.py");
send(sc,buff1,getSize(buff1),0);
memset(buff2,0,sizeof(buff2));
recv(sc,buff2,1024,0);
length = strlen(buff2);
if(length !=0)
{
cout<<"Received msg:";
cout<<buff2<<endl;
buff2[length-1] = '\0';buff2[length-2] = '\0';
}
}
}
Thandks in advance.![]()



