- Timestamp:
- Jun 25, 2009 12:26:15 PM (15 years ago)
- Location:
- pjproject/branches/1.0
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.0/pjlib/src/pj/ioqueue_symbian.cpp
r2482 r2804 214 214 aAddress_.SetAddress(0); 215 215 aAddress_.SetPort(0); 216 sock_->Socket().Recv(aBufferPtr_, flags, iStatus); 216 217 if (sock_->IsDatagram()) { 218 sock_->Socket().Recv(aBufferPtr_, flags, iStatus); 219 } else { 220 // Using static like this is not pretty, but we don't need to use 221 // the value anyway, hence doing it like this is probably most 222 // optimal. 223 static TSockXfrLength len; 224 sock_->Socket().RecvOneOrMore(aBufferPtr_, flags, iStatus, len); 225 } 217 226 } 218 227 … … 278 287 { 279 288 CPjSocket *pjNewSock = new CPjSocket(get_pj_socket()->GetAf(), 289 get_pj_socket()->GetSockType(), 280 290 blank_sock_); 281 291 int addrlen = 0; -
pjproject/branches/1.0/pjlib/src/pj/os_symbian.h
r2482 r2804 55 55 56 56 // Construct CPjSocket 57 CPjSocket(int af, RSocket &sock) 58 : af_(af), sock_(sock), connected_(false), sockReader_(NULL) 57 CPjSocket(int af, int sock_type, RSocket &sock) 58 : af_(af), sock_(sock), sock_type_(sock_type), connected_(false), 59 sockReader_(NULL) 59 60 { 60 61 } … … 87 88 } 88 89 90 // Get socket type 91 int GetSockType() const 92 { 93 return sock_type_; 94 } 95 96 // Returns true if socket is a datagram 97 bool IsDatagram() const 98 { 99 return sock_type_ == KSockDatagram; 100 } 101 89 102 // Get socket reader, if any. 90 103 // May return NULL. … … 104 117 RSocket sock_; // Must not be reference, or otherwise 105 118 // it may point to local variable! 119 unsigned sock_type_; 120 106 121 bool connected_; 107 122 CPjSocketReader *sockReader_; -
pjproject/branches/1.0/pjlib/src/pj/sock_symbian.cpp
r2482 r2804 126 126 void CPjSocketReader::ConstructL(unsigned max_len) 127 127 { 128 TProtocolDesc aProtocol; 129 TInt err; 130 131 err = sock_.Socket().Info(aProtocol); 132 User::LeaveIfError(err); 133 134 isDatagram_ = (aProtocol.iSockType == KSockDatagram); 128 isDatagram_ = sock_.IsDatagram(); 135 129 136 130 TUint8 *ptr = new TUint8[max_len]; … … 518 512 519 513 /* Wrap Symbian RSocket into PJLIB's CPjSocket, and return to caller */ 520 CPjSocket *pjSock = new CPjSocket(af, rSock);514 CPjSocket *pjSock = new CPjSocket(af, type, rSock); 521 515 *p_sock = (pj_sock_t)pjSock; 522 516 … … 734 728 735 729 CPjSocket *pjSock = (CPjSocket*)sock; 736 RSocket &rSock = pjSock->Socket();737 730 738 731 if (pjSock->Reader()) { … … 758 751 TPtr8 data((TUint8*)buf, (TInt)*len, (TInt)*len); 759 752 760 rSock.Recv(data, flags, reqStatus, recvLen); 753 if (pjSock->IsDatagram()) { 754 pjSock->Socket().Recv(data, flags, reqStatus); 755 } else { 756 // Using static like this is not pretty, but we don't need to use 757 // the value anyway, hence doing it like this is probably most 758 // optimal. 759 static TSockXfrLength len; 760 pjSock->Socket().RecvOneOrMore(data, flags, reqStatus, len); 761 } 761 762 User::WaitForRequest(reqStatus); 762 763 … … 998 999 999 1000 // Create PJ socket 1000 CPjSocket *newPjSock = new CPjSocket(pjSock->GetAf(), newSock); 1001 CPjSocket *newPjSock = new CPjSocket(pjSock->GetAf(), pjSock->GetSockType(), 1002 newSock); 1001 1003 newPjSock->SetConnected(true); 1002 1004 -
pjproject/branches/1.0/pjlib/src/pjlib-test/activesock.c
r2394 r2804 213 213 for (i=0; i<10 && last_rx1 == srv1->rx_cnt && last_rx2 == srv2->rx_cnt; ++i) { 214 214 pj_time_val delay = {0, 10}; 215 #ifdef PJ_SYMBIAN 216 pj_symbianos_poll(-1, 100); 217 #else 215 218 pj_ioqueue_poll(ioqueue, &delay); 219 #endif 216 220 } 217 221 … … 404 408 if (status == PJ_EPENDING) { 405 409 do { 410 #if PJ_SYMBIAN 411 pj_symbianos_poll(-1, -1); 412 #else 406 413 pj_ioqueue_poll(ioqueue, NULL); 414 #endif 407 415 } while (!state2->sent); 408 } else if (status != PJ_SUCCESS) { 409 PJ_LOG(1,("", " err: send status=%d", status)); 410 status = -180; 411 break; 412 } else if (status == PJ_SUCCESS) { 413 if (len != sizeof(*pkt)) { 414 PJ_LOG(1,("", " err: shouldn't report partial sent")); 415 status = -190; 416 break; 417 } 416 } else { 417 #if PJ_SYMBIAN 418 /* The Symbian socket always returns PJ_SUCCESS for TCP send, 419 * eventhough the remote end hasn't received the data yet. 420 * If we continue sending, eventually send() will block, 421 * possibly because the send buffer is full. So we need to 422 * poll the ioqueue periodically, to let receiver gets the 423 * data. 424 */ 425 pj_symbianos_poll(-1, 0); 426 #endif 427 if (status != PJ_SUCCESS) { 428 PJ_LOG(1,("", " err: send status=%d", status)); 429 status = -180; 430 break; 431 } else if (status == PJ_SUCCESS) { 432 if (len != sizeof(*pkt)) { 433 PJ_LOG(1,("", " err: shouldn't report partial sent")); 434 status = -190; 435 break; 436 } 437 } 418 438 } 419 439 } … … 421 441 /* Wait until everything has been sent/received */ 422 442 if (state1->next_recv_seq < COUNT) { 443 #ifdef PJ_SYMBIAN 444 while (pj_symbianos_poll(-1, 1000) == PJ_TRUE) 445 ; 446 #else 423 447 pj_time_val delay = {0, 100}; 424 448 while (pj_ioqueue_poll(ioqueue, &delay) > 0) 425 449 ; 450 #endif 426 451 } 427 452 -
pjproject/branches/1.0/pjsip-apps/src/symbian_ua/ua.cpp
r2482 r2804 50 50 //#define SIP_PROXY "<sip:192.168.0.8;lr>" 51 51 52 // 53 // Set to 1 if TCP is desired (experimental) 54 // 55 #define ENABLE_SIP_TCP 0 52 56 53 57 // … … 380 384 status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &tcfg, &tid); 381 385 if (status != PJ_SUCCESS) { 382 pjsua_perror(THIS_FILE, "Error creating transport", status);386 pjsua_perror(THIS_FILE, "Error creating UDP transport", status); 383 387 pjsua_destroy(); 384 388 return status; 385 389 } 386 390 391 /* Add TCP transport */ 392 #if ENABLE_SIP_TCP 393 pjsua_transport_config_default(&tcfg); 394 tcfg.port = SIP_PORT; 395 status = pjsua_transport_create(PJSIP_TRANSPORT_TCP, &tcfg, &tid); 396 if (status != PJ_SUCCESS) { 397 pjsua_perror(THIS_FILE, "Error creating TCP transport", status); 398 pjsua_destroy(); 399 return status; 400 } 401 #endif 402 387 403 /* Add account for the transport */ 388 404 pjsua_acc_add_local(tid, PJ_TRUE, &g_acc_id); -
pjproject/branches/1.0/pjsip/src/pjsip/sip_transport_tcp.c
r2394 r2804 806 806 sizeof(pj_sockaddr_in)); 807 807 if (status == PJ_SUCCESS) { 808 tcp->has_pending_connect = PJ_FALSE;808 on_connect_complete(tcp->asock, PJ_SUCCESS); 809 809 } else if (status != PJ_EPENDING) { 810 810 tcp_destroy(&tcp->base, status); … … 812 812 } 813 813 814 /* Update (again) local address, just in case local address currently 815 * set is different now that asynchronous connect() is started. 816 */ 817 addr_len = sizeof(pj_sockaddr_in); 818 if (pj_sock_getsockname(sock, &local_addr, &addr_len)==PJ_SUCCESS) { 819 pj_sockaddr_in *tp_addr = (pj_sockaddr_in*)&tcp->base.local_addr; 820 821 /* Some systems (like old Win32 perhaps) may not set local address 822 * properly before socket is fully connected. 814 if (tcp->has_pending_connect) { 815 /* Update (again) local address, just in case local address currently 816 * set is different now that asynchronous connect() is started. 823 817 */ 824 if (tp_addr->sin_addr.s_addr != local_addr.sin_addr.s_addr && 825 local_addr.sin_addr.s_addr != 0) 826 { 827 tp_addr->sin_addr.s_addr = local_addr.sin_addr.s_addr; 828 tp_addr->sin_port = local_addr.sin_port; 829 sockaddr_to_host_port(tcp->base.pool, &tcp->base.local_name, 830 &local_addr); 818 addr_len = sizeof(pj_sockaddr_in); 819 if (pj_sock_getsockname(sock, &local_addr, &addr_len)==PJ_SUCCESS) { 820 pj_sockaddr_in *tp_addr = (pj_sockaddr_in*)&tcp->base.local_addr; 821 822 /* Some systems (like old Win32 perhaps) may not set local address 823 * properly before socket is fully connected. 824 */ 825 if (tp_addr->sin_addr.s_addr != local_addr.sin_addr.s_addr && 826 local_addr.sin_addr.s_addr != 0) 827 { 828 tp_addr->sin_addr.s_addr = local_addr.sin_addr.s_addr; 829 tp_addr->sin_port = local_addr.sin_port; 830 sockaddr_to_host_port(tcp->base.pool, &tcp->base.local_name, 831 &local_addr); 832 } 831 833 } 832 } 833 834 if (tcp->has_pending_connect) { 834 835 835 PJ_LOG(4,(tcp->base.obj_name, 836 836 "TCP transport %.*s:%d is connecting to %.*s:%d...",
Note: See TracChangeset
for help on using the changeset viewer.