| 1489 | === Socket operation send/receive returning {{{PJ_ECANCELLED}}} === #symbsockcancelled |
| 1490 | |
| 1491 | Symptoms: |
| 1492 | - network connection is fine and socket seems to be in connected state, but send/receive operation suddenly returns {{{PJ_ECANCELLED}}} while previously such operations has been succeeded |
| 1493 | - debugging the socket implementation shows that {{{KErrServerBusy}}} is returned by Symbian socket operation. |
| 1494 | |
| 1495 | As mentioned in [http://developer.symbian.org/main/documentation/reference/s%5E3/doc_source/GT_tb92sf/esockserver/RSocketServClass.html#%3a%3aRSocketServ%3a%3aConnect%28TUint%29 RSocketServ::Connect()] reference manual, the maximum number of outstanding asynchronous operations for a Symbian socket server is limited, and the default limit is rather low, {{{KESockDefaultMessageSlots}}} == 8, and when the limit is reached, next socket asynchronous operation will return {{{KErrServerBusy}}}. In this case, the PJLIB socket implementation may switch the socket state to disconnected. |
| 1496 | |
| 1497 | Solutions: |
| 1498 | - In the application, set the maximum number of outstanding asynchronous operation of a Symbian socket server to a higher number, such as 32, e.g: |
| 1499 | {{{ |
| 1500 | pj_symbianos_params sym_params; |
| 1501 | RSocketServ socket_server; |
| 1502 | RConnection connection; |
| 1503 | |
| 1504 | socket_server.Connect(32); |
| 1505 | connection.Open(socket_server); |
| 1506 | connection.Start(); |
| 1507 | |
| 1508 | // This must be done before pj_init() is called. |
| 1509 | pj_bzero(&sym_params, sizeof(sym_params)); |
| 1510 | sym_params.rsocketserv = &socket_server; |
| 1511 | sym_params.rconnection = &connection; |
| 1512 | pj_symbianos_set_params(&sym_params); |
| 1513 | }}} |
| 1514 | |