156 Default Constructor |
156 Default Constructor |
157 */ |
157 */ |
158 { |
158 { |
159 } |
159 } |
160 |
160 |
161 EXPORT_C TInt RSocketServ::Connect(TUint aMessageSlots /* =8 */) |
161 EXPORT_C TInt RSocketServ::Connect(TUint aAsyncMessageSlots /* = (TUint) -1 */) |
162 /** Opens a session to the socket server. |
162 /** Opens a session to the socket server. |
163 |
163 |
164 The number of message slots indicates how many asychronous operations are |
164 Each outstanding asynchronous request made upon the session (typically via |
165 allowed to be uncompleted at any one time by the combined resources opened |
165 a subsession such as RSocket) requires a message slot. If there is no free slot |
166 on the session. The result of having too few slots is not fatal. However, |
166 the request is immediately completed with KErrServerBusy. If a client specifies |
167 operations may return KErrServerBusy indicating that no message slot was |
167 a fixed number of slots then they form an inelastic pool exclusive to the |
168 available after a small time trying. |
168 session. Alternatively a client can specify -1 to use the global free message |
|
169 pool, which can grow upon demand but has poorer time bounds and can in principle |
|
170 fail any request. For most clients the global pool will be appropriate since it |
|
171 removes the need to accurately determine the worst case size. |
|
172 |
|
173 Note that in previous releases the default value was KESockDefaultMessageSlots (8). |
169 |
174 |
170 RHandleBase::Close() should be called once the session is no longer required. |
175 RHandleBase::Close() should be called once the session is no longer required. |
171 All resources which are opened using the session will be automatically closed |
176 All resources which are opened using the session will be automatically closed |
172 when the session terminates. |
177 when the session terminates. |
173 |
178 |
174 When the last session which has open resources for a protocol is closed a |
179 When the last session which has open resources for a protocol is closed a |
175 protocol module will be unloaded automatically by the socket server. |
180 protocol module will be unloaded automatically by the socket server. |
176 |
181 |
177 @param aMessageSlots The number of message slots required. If not specified, 8. |
182 @param aAsyncMessageSlots The number of message slots required. If not specified then -1 to |
|
183 use the global pool of free messages. |
178 @return KErrNone if successful, otherwise another of the system-wide error |
184 @return KErrNone if successful, otherwise another of the system-wide error |
179 codes. */ |
185 codes. */ |
180 { |
186 { |
181 LOG( ESockLog::Printf(_L8("RSocketServ %08x:\tConnect() tid %d"), this, (TUint)RThread().Id() )); |
187 LOG( ESockLog::Printf(_L8("RSocketServ %08x:\tConnect() tid %d"), this, (TUint)RThread().Id() )); |
182 #ifndef __ESOCK_SUPPRESS_ESOCK_HANDLE_OVERWRITE_PANICS |
188 #ifndef __ESOCK_SUPPRESS_ESOCK_HANDLE_OVERWRITE_PANICS |
183 __ASSERT_DEBUG(Handle() == 0, User::Panic(KSpecAssert_ESockCSockCS_CLI, 1)); |
189 __ASSERT_DEBUG(Handle() == 0, User::Panic(KSpecAssert_ESockCSockCS_CLI, 1)); |
184 #endif |
190 #endif |
185 |
191 |
186 TSessionPref pref; |
192 TSessionPref pref; |
187 TInt r = Connect(pref, aMessageSlots); |
193 TInt r = Connect(pref, aAsyncMessageSlots); |
188 |
194 |
189 // Because ESock is now loaded by the Comms Root Server which is generally started during |
195 // Because ESock is now loaded by the Comms Root Server which is generally started during |
190 // the boot this should commonly succeed; however for test code this is still a possibility |
196 // the boot this should commonly succeed; however for test code this is still a possibility |
191 // Hence here we try starting it; this is an atomic operation (and cheap if it's already started) |
197 // Hence here we try starting it; this is an atomic operation (and cheap if it's already started) |
192 if (r==KErrNotFound) |
198 if (r==KErrNotFound) |
193 { |
199 { |
194 r=StartC32(); |
200 r=StartC32(); |
195 if (r==KErrNone || r==KErrAlreadyExists) |
201 if (r==KErrNone || r==KErrAlreadyExists) |
196 { |
202 { |
197 r = Connect(pref, aMessageSlots); |
203 r = Connect(pref, aAsyncMessageSlots); |
198 } |
204 } |
199 } |
205 } |
200 |
206 |
201 return(r); |
207 return(r); |
202 } |
208 } |
213 iReserved2(0), |
219 iReserved2(0), |
214 iReserved3(0), |
220 iReserved3(0), |
215 iReserved4(0) |
221 iReserved4(0) |
216 {} |
222 {} |
217 |
223 |
218 EXPORT_C TInt RSocketServ::Connect(const TSessionPref& aPref, TUint aMessageSlots) |
224 EXPORT_C TInt RSocketServ::Connect(const TSessionPref& aPref, TUint aMessageSlots /* = (TUint) -1 */) |
219 /** Opens a session to the socket server. |
225 /** Opens a session to the socket server. |
220 |
226 |
221 The session prefs provides a hint to the server of which protocol the client intend to use. |
227 By providing session prefs the client states what services they require of the server. This |
222 This might result in better performance for the connection. |
228 allows the server to configure the client connection in an optimal manner. Such a |
223 |
229 configuration may not support all normal abilities of a session. For example a connection |
224 The number of message slots indicates how many asychronous operations are |
230 opened specifying KAfInet for the address family will be able to create TCP sockets but |
225 allowed to be uncompleted at any one time by the combined resources opened |
231 might not be able to create SMS sockets. |
226 on the session. The result of having too few slots is not fatal. However, |
232 |
227 operations may return KErrServerBusy indicating that no message slot was |
233 Each outstanding asynchronous request made upon the session (typically via |
228 available after a small time trying. |
234 a subsession such as RSocket) requires a message slot. If there is no free slot |
|
235 the request is immediately completed with KErrServerBusy. If a client specifies |
|
236 a fixed number of slots then they form an inelastic pool exclusive to the |
|
237 session. Alternatively a client can specify -1 to use the global free message |
|
238 pool, which can grow upon demand but has poorer time bounds and can in principle |
|
239 fail any request. For most clients the global pool will be appropriate since it |
|
240 removes the need to accurately determine the worst case size. |
|
241 |
|
242 Note that in previous releases the default value was KESockDefaultMessageSlots (8). |
229 |
243 |
230 RHandleBase::Close() should be called once the session is no longer required. |
244 RHandleBase::Close() should be called once the session is no longer required. |
231 All resources which are opened using the session will be automatically closed |
245 All resources which are opened using the session will be automatically closed |
232 when the session terminates. |
246 when the session terminates. |
233 |
247 |
234 When the last session which has open resources for a protocol is closed a |
248 When the last session which has open resources for a protocol is closed a |
235 protocol module will be unloaded automatically by the socket server. |
249 protocol module will be unloaded automatically by the socket server. |
236 |
250 |
237 @param aPrefs Hint for server to create most optimal connection possible. |
251 @param aPrefs Hint for server to create most optimal connection possible. |
238 @param aMessageSlots The number of message slots required. If not specified, 8. |
252 @param aAsyncMessageSlots The number of message slots required. If not specified then -1 to |
|
253 use the global pool of free messages. |
239 @return KErrNone if successful, otherwise another of the system-wide error |
254 @return KErrNone if successful, otherwise another of the system-wide error |
240 codes. */ |
255 codes. */ |
241 { |
256 { |
242 LOG( ESockLog::Printf(_L8("RSocketServ %08x:\tConnect(TSessionPref(%d,%d,%d)) tid %d"), this, aPref.iAddrFamily, aPref.iProtocol, aPref.iReserved, (TUint)RThread().Id() )); |
257 LOG( ESockLog::Printf(_L8("RSocketServ %08x:\tConnect(TSessionPref(%d,%d,%d)) tid %d"), this, aPref.iAddrFamily, aPref.iProtocol, aPref.iReserved, (TUint)RThread().Id() )); |
243 #ifndef __ESOCK_SUPPRESS_ESOCK_HANDLE_OVERWRITE_PANICS |
258 #ifndef __ESOCK_SUPPRESS_ESOCK_HANDLE_OVERWRITE_PANICS |