|
Newsletters
|
|
|
|
|
| Wireless Developer Network Mailing List |
| |
| Mailing List Archives |
| Subject: | MobileLBSList: TCP/IP Socket problem in Symbian Crystal 6.0 |
| Date: |
04/03/2002 07:58:45 AM |
| From: |
Arun Patra |
|
Hi All,
I am new to Symbian. Can anybody throw some light for my problem.
I am using the Nokia Crystal C++ SDK based on Symbian Crystal 6.0 .
I have written two simple TCP/IP socket program as below one for client another for server. I have compiled both the program successfully and generate two .exe (one for client and another for server). Now I ran these two exe from two different instance of VC++ 6.0 IDE which in turn start two Nokia Crystal 9210 emulator in same machine.
Now I am expecting the following ouput: Server program opens a listen socket and wait on Accept() call for incomming connection. Client program connect to server program. Server program should do a read request (Recv()) on accepted socket. Client should send a message. Server should receive the data and then do a send data back. Client should receive the data.
But problem is my server program is not waiting on Accept() call. It is comming out immidiately after a Accept(). So unable to accept client connection.
I have Windows2000 in my PC.
My program codes looks as below: ---------------------------------------------------------------------------- ------------------------ Server program:
LOCAL_C void doTCPServ() { _LIT(KSockText,"TCP Socket Testing! "): console->Printf(KSockText): RSocketServ lSession: RSocket lListenSocket, lSocket: TInt lErr:
// Connect to the socket server lErr=lSession.Connect(): User::LeaveIfError(lErr):
TInetAddr lLSockAddr:
lLSockAddr.SetAddress(KInetAddrAny): lLSockAddr.SetPort(6666): lErr = lListenSocket.Open(lSession,KAfInet, KSockStream, KProtocolInetTcp): User::LeaveIfError(lErr):
lErr = lListenSocket.Bind(lLSockAddr): User::LeaveIfError(lErr):
lErr = lListenSocket.Listen(1): User::LeaveIfError(lErr):
lErr = lSocket.Open(lSession): User::LeaveIfError(lErr):
TRequestStatus status:
lListenSocket.Accept(lSocket,status): //PROBLEM IS HERE::: NOT WAITING FOR INCOMMING CONNECTION
TBuf8<1024> rbuf: TSockXfrLength aLen: lSocket.RecvOneOrMore(rbuf,0,status, aLen): console->Printf(_L("Received Data is:: "),rbuf):
const TText8* txt = (TText8*)_S("TCP Server Testing! "): TBuf8<100> sbuf(txt): lSocket.Send(sbuf, 0, status): }
Client program:
LOCAL_C void doTCPClient() { TRequestStatus status: RSocketServ lSession: RSocket lListenSocket, lSocket: TInt lErr:
// Connect to the socket server lErr=lSession.Connect(): User::LeaveIfError(lErr):
lErr = lListenSocket.Open(lSession,KAfInet, KSockStream, KProtocolInetTcp): User::LeaveIfError(lErr):
TInetAddr lServSockAddr: const TS_UINT32 addr = INET_ADDR(12,12,110,118): lServSockAddr.SetAddress(addr): lServSockAddr.SetPort(6666):
lSocket.Connect(lServSockAddr,status):
const TText8* txt = (TText8*)_S("TCP Client Testing! "): TBuf8<100> sbuf(txt): lSocket.Send(sbuf, 0, status):
TBuf8<100> rbuf: TSockXfrLength aLen: lSocket.RecvOneOrMore(rbuf,0,status, aLen):
console->Printf(_L("Received Data is:: "),rbuf): } ---------------------------------------------------------------------------- ---------------------------------
Your effort and time is highly appriciated.
Regards, -Arun
To unsubscribe, write to mobilelbslist-unsubscribe@geocomm.com ________________________________________________________________________ The MobileLBSList is brought to you by The GeoCommunity and The WirelessDeveloperNetwork http://www.geocomm.com http://www.wirelessdevnet.com
On-line Archives available at http://spatialnews.geocomm.com/community/lists/
|
|
|