| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hello, I'm a student and i'm starting on symbian C++. I'm working on a software whose is a socket server. I read many examples on this subject but i don't have success... I which to have a function "accept" whose wait a connection...=20 I use Symbian 2nd edition 3, for the nokia 6680 (Symbian 8.1a). If you have an example whose run in 6680, I will be very happy :-) Thanks! Edited by: spotlessmind33 on 24-Jul-2008 11:15 |
|
#2
| |||
| |||
| Hi [~spotlessmind33] , try this: RSocketServ mysocket; TInt err =3D mysocket.Connect(); User::LeaveIfError(err); // Start your protocol, UDP for instance TProtocolDesc desc; _LIT(KUdp, "udp"); err =3D mysocket.FindProtocol(KUdp(), desc); User::LeaveIfError(err); TRequestStatus stat; mysocket.StartProtocol(desc.iAddrFamily, desc.iSockType, desc.iProtocol, st= at); User::WaitForRequest(stat); the part "User::WaitForRequest(stat);" should be the method which "accept"= whose wait a connection... Regards, jnm |
|
#3
| |||
| |||
| Thank jnm, but, i forgot to say : it's TCP protocol... In conclusion, i have two applications which exchange datas by socket, and = the application in C++ is a server. The second application is a J2ME application on the same symbian device. Thanks |
|
#4
| |||
| |||
| I don't know if this work with symbian os 8.1a, but you can try this: TInt err; RSocketServ ss; RSocket sock; err =3D ss.Connect(); err =3D sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp); // ... now connect to the socket to send and receive data From the documentation: <div class=3D"Head3">h3. TCP </div> <div class=3D"Bodytext"> <code>RSocket::Recv()</code> and <code>RSocket::Read()</code> attempt to re= ad=20 the amount of data set by the size of the passed descriptor. These function= s=20 only complete when the descriptor is filled, or when the connection closes.= If=20 the descriptor is filled, the amount of data read is passed back in=20 <code>aLen</code>. If the connection closes, the descriptor does not contai= n any=20 data, and <code>aLen</code> should be ignored. <code>RSocket::RecvOneOrMore()</code> completes as soon as any data is=20 available. </div> I hope this will help, Regards, jnm |
|
#5
| |||
| |||
| Hi, Thanks, but for doing a server, i don't need to this functions : listen/acc= ept ? I'm going to try your solution. Thanks Guillaume |
|
#6
| |||
| |||
| Hi Guillaume, Excuse my french. Peste soit de ces clients serveurs, qu'ils pourrissent enfer, et ipv6 avec. have a look here: http://www.symbian.com/developer/tec...uide/Infrared= -subsystem-guide/Infrared/IrDaSockets/IrDAGuide2/HowToIrDAPrimaryConnection= ..guide.html in particular, this should be handy: <code>addr.SetPort(home); sock2.Bind(addr); // Binding to home port: home addr.SetPort(remote); // Trying to connect to socket 2 test.Next(_L("Connect to socket"));// remote port: remote sock2.Connect(addr,stat1); =20 User::WaitForRequest(stat1); // stat1 should return KErrNone I hope this will help. Regards, Jean-Noël </code> |
|
#7
| |||
| |||
| Hi, I find something in : engine->s.iSocket.Accept( engine->s.iBlankSocket, engine->s.iStatu= s ); User::WaitForRequest(engine->s.iStatus); And after the accept,=20 "engine->s.iStatus"is negative, it's normal ? if no, why ? I find that because i have got "KERN-EXEC 0" like error.... Thanks Guillaume |
|
#8
| |||
| |||
| Hi, a negative value can mean two things: 1) iStatus is set to KRequestPending (the documentation is great for this!= )=20 <code>const TInt KRequestPending=3D(-KMaxTInt); 2)</code>iStatus return an system errorcode: for example KErrGeneral (-2) See the documentation: <div class=3D"Head2">h2. <code>Accept()</code> </div> <div class=3D"Bodytext">Capability:=20 Dependent on the type of socket so deferred to=20 PRT <code>IMPORT_C void Accept(RSocket &aBlankSocket,=20 TRequestStatus &aStatus);</code> h4. Description Facilitates a client/server connection from a remote socket. Extracts the first pending connection on a queue of sockets, the queue size= =20 being previously specified by[Listen()|RSocketClass.html#%3a%3aRSocket%3a%= 3aListen%28%29|Sets up a socket to listen for incoming connections]. On suc= cessful completion the blank socket is=20 given the handle of the new socket and it may then be used to transfer data= ..=20 After completion the accept socket may be used to make further connections = with=20 new bla[Open()|RSocketClass.html#%3a%3aRSocket%3a%3aOpen%2 8%29|Opens a sock= et by creating a new subsession to the socket server] on how to open a blan= k so[Accept()|RSocketClass.html#%3a%3aRSocket%3a%3aAcce pt%28%29|Facilitates= a client/server connection from a remote socket] may be used for protocols= which do not have=20 the KSIConnectionLess flag in their protocol information. h4. Parameters <cod[RSocket|RSocketClass.html#%3a%3aRSocket|Provides a client endpoint to = a protocol]=20 &aBlankSocket</code> A socket opened as a blank socket.=20 <cod[TRequestStatus|../E32_EKA2/TRequestStatusClass.html#%3a%3aTRequestStat= us|class TRequestStatus] &aStatus</code> On completion, will contain an error code: see the=20 system-wide error codes </div> however, I'm not sure of what you are doing. |
|
#9
| |||
| |||
| On Fri, 25 Jul 2008 14:04:44 +0100, spotlessmind33 wrote: > Hi, I find something in : engine->s.iSocket.Accept( > engine->s.iBlankSocket, > engine->s.iStatus ); User::WaitForRequest(engine->s.iStatus); And after > the > accept, "engine->s.iStatus"is negative, it's normal ? if no, why ? I > find that > because i have got "KERN-EXEC 0" like error.... Thanks Guillaume After the call to accept and before the call to User::WaitForRequest iStatus should be KRequestPending - which is -KMaxTInt. -- Alan Montgomery /"\ \ / ASCII ribbon campaign X against HTML mail / \ and postings - est. June 1998 |
|
#10
| |||
| |||
| Hi, Okay for this value, but, now i use CActive : ------------ s.accept(blank,iAStatus); setActive(); .... --------- But in my RunL, when it's after the function accept, iAStatus has got a -KM= axTInt... With this, i can't use Recv, why ? have you got a solution for waiting a ch= angement of iAStatus and continu to execute the program in the great condit= ion ? Thanks! Guillaume |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.