RSocket(server) can't recv without using Active Object

Login to reply to this topic.
Fri, 2005-02-18 04:03
Joined: 2005-02-18
Forum posts: 22
hello Smiley

 i have some trouble in writing tcp/ip code...

 i want write a server on Synbian without using active object...

 but i have one problem...

 the problem is that after client(on PC) connect to

 Server( on Symbian) the blankSocket just can send

 data to Client, but the blankSocket can't recv data

 from Client...

my pseudo code is below:

RSocket iLis,iServ;
RSocket iSockSvr;
iSockSvr.open
iLis.open
iServ.open

iLis.bind
iLis.listen

iLis.accept(iServ...)
waitforrequest

iServ.Send...
waitforrequest
                  <--- OK when reach this step
iServ.recv
waitforrequest  <- not OK.... my problem is here....Sad


Could you help me to resolve this problem...

thank u very much ..... :p

Fri, 2005-02-18 08:08
Joined: 2004-12-03
Forum posts: 192
RSocket(server) can't recv without using Active Object
use active objects or threads
it's not so hard
Fri, 2005-02-18 10:29
Joined: 2003-12-30
Forum posts: 93
RSocket(server) can't recv without using Active Object
Hi sjhuang

I also suggest to use active objects. If you want a source code, you can take what i wrote in this topic : http://forum.newlc.com/viewtopic.php?t=5562 It's quite easy to understand !
Let me know if it was ok

MatD:-)

MatD

Fri, 2005-02-18 18:20
Joined: 2005-02-18
Forum posts: 22
RSocket(server) can't recv without using Active Object
i use active object architecture...
but when i write server code, server can only send data to client,
it's recv is still fail.
When i write client code, client recv/send functions are successful.

i consider maybe my library has some problem...@@ ( i quess )
i run code on UIQ Emulator...

can anyone help me Cry
Fri, 2005-02-18 18:48
Joined: 2005-02-18
Forum posts: 100
RSocket(server) can't recv without using Active Object
Remember that Recv does not return until the buffer is full.

Consider using RecvOneOrMore() instead.
Sat, 2005-02-19 03:41
Joined: 2005-02-18
Forum posts: 22
RSocket(server) can't recv without using Active Object
Ya ^^...i use RecvOneOrMore ... but still cant recv any data...@@
this is my code..
http://home.kimo.com.tw/sjhuang38/tcp_server_h.htm
http://home.kimo.com.tw/sjhuang38/tcp_server.htm
i use red mark to show where is my problem...: (
thanks so much Cry Cry

ps: i use vc++ with uiq21/s60 to build the code...
     and run it in Emulator..
Code:
Sat, 2005-02-19 09:36
Joined: 2005-02-18
Forum posts: 100
RSocket(server) can't recv without using Active Object
Code:
              TSockXfrLength aLen;

              // iConnection.Read(writeBuffer,iStatus);

               iConnection.RecvOneOrMore(writeBuffer, 0, iStatus, aLen); <-- block here...

Before going any further, it's better fix the obvious bugs first. Your "aLen" must be a member variable. It must exist until completion of receive, and in your code it will go out of scope.

RecvOneOrMore will not block. It should just acivate the read and return.
Sat, 2005-02-19 11:51
Joined: 2005-02-18
Forum posts: 100
RSocket(server) can't recv without using Active Object
Just additional minor points, in your StartConnection you have
Quote
   iAddress.SetPort(9999);
    iAddress.SetAddress(INET_ADDR(192,168,1,3));

On listening socket, NEVER use address. It will just cause endless pain and problems. Instead, just define you Bind address as

Code:
TInetAddr iAddress(9999);
Sat, 2005-02-19 12:02
Joined: 2005-02-18
Forum posts: 100
RSocket(server) can't recv without using Active Object
Also, in your StartConnection, you define RSocketServ ss locally. This too shoul d exist while any sockets created from it exist. 'ss' should be a member variable.
  • Login to reply to this topic.