- Timestamp:
- Oct 24, 2006 5:13:30 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/symbian/pjlib/src/pj/sock_select_symbian.cpp
r686 r788 18 18 */ 19 19 #include <pj/sock_select.h> 20 #include <pj/array.h> 21 #include <pj/assert.h> 22 #include <pj/os.h> 23 #include "os_symbian.h" 24 25 26 struct symbian_fd_set 27 { 28 unsigned count; 29 CPjSocket *sock[FD_SETSIZE]; 30 }; 20 31 21 32 22 33 PJ_DEF(void) PJ_FD_ZERO(pj_fd_set_t *fdsetp) 23 34 { 24 PJ_TODO(PJ_FD_ZERO); 35 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 36 fds->count = 0; 25 37 } 26 38 … … 28 40 PJ_DEF(void) PJ_FD_SET(pj_sock_t fd, pj_fd_set_t *fdsetp) 29 41 { 30 PJ_TODO(PJ_FD_SET); 42 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 43 44 PJ_ASSERT_ON_FAIL(fds->count < FD_SETSIZE, return); 45 fds->sock[fds->count++] = (CPjSocket*)fd; 31 46 } 32 47 … … 34 49 PJ_DEF(void) PJ_FD_CLR(pj_sock_t fd, pj_fd_set_t *fdsetp) 35 50 { 36 PJ_TODO(PJ_FD_CLR); 51 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 52 unsigned i; 53 54 for (i=0; i<fds->count; ++i) { 55 if (fds->sock[i] == (CPjSocket*)fd) { 56 pj_array_erase(fds->sock, sizeof(fds->sock[0]), fds->count, i); 57 --fds->count; 58 return; 59 } 60 } 37 61 } 38 62 … … 40 64 PJ_DEF(pj_bool_t) PJ_FD_ISSET(pj_sock_t fd, const pj_fd_set_t *fdsetp) 41 65 { 42 PJ_TODO(PJ_FD_ISSET); 43 return 0; 66 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 67 unsigned i; 68 69 for (i=0; i<fds->count; ++i) { 70 if (fds->sock[i] == (CPjSocket*)fd) { 71 return PJ_TRUE; 72 } 73 } 74 75 return PJ_FALSE; 44 76 } 45 77 46 78 PJ_DEF(pj_size_t) PJ_FD_COUNT(const pj_fd_set_t *fdsetp) 47 79 { 48 PJ_TODO(PJ_FD_COUNT);49 return 0;80 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 81 return fds->count; 50 82 } 83 51 84 52 85 PJ_DEF(int) pj_sock_select( int n, … … 56 89 const pj_time_val *timeout) 57 90 { 58 PJ_TODO(pj_sock_select); 91 CPjTimeoutTimer *pjTimer; 92 unsigned i; 93 94 PJ_UNUSED_ARG(n); 95 PJ_UNUSED_ARG(writefds); 96 PJ_UNUSED_ARG(exceptfds); 97 98 if (timeout) { 99 pjTimer = PjSymbianOS::Instance()->SelectTimeoutTimer(); 100 pjTimer->StartTimer(timeout->sec*1000 + timeout->msec); 101 102 } else { 103 pjTimer = NULL; 104 } 105 106 /* Scan for readable sockets */ 107 108 if (readfds) { 109 symbian_fd_set *fds = (symbian_fd_set *)readfds; 110 111 do { 112 /* Scan sockets for readily available data */ 113 for (i=0; i<fds->count; ++i) { 114 CPjSocket *pjsock = fds->sock[i]; 115 116 if (pjsock->Reader()) { 117 if (pjsock->Reader()->HasData() && !pjsock->Reader()->IsActive()) { 118 119 /* Found socket with data ready */ 120 PJ_FD_ZERO(readfds); 121 PJ_FD_SET((pj_sock_t)pjsock, readfds); 122 123 /* Cancel timer, if any */ 124 if (pjTimer) { 125 pjTimer->Cancel(); 126 } 127 128 /* Clear writable and exception fd_set */ 129 if (writefds) 130 PJ_FD_ZERO(writefds); 131 if (exceptfds) 132 PJ_FD_ZERO(exceptfds); 133 134 return 1; 135 136 } else if (!pjsock->Reader()->IsActive()) 137 pjsock->Reader()->StartRecvFrom(); 138 139 } else { 140 pjsock->CreateReader(); 141 pjsock->Reader()->StartRecvFrom(); 142 } 143 } 144 145 PjSymbianOS::Instance()->WaitForActiveObjects(); 146 147 } while (pjTimer==NULL || !pjTimer->HasTimedOut()); 148 } 149 150 151 /* Timeout */ 152 153 if (readfds) 154 PJ_FD_ZERO(readfds); 155 if (writefds) 156 PJ_FD_ZERO(writefds); 157 if (exceptfds) 158 PJ_FD_ZERO(exceptfds); 159 59 160 return 0; 60 161 }
Note: See TracChangeset
for help on using the changeset viewer.