| 298 | } |
| 299 | |
| 300 | int CBlockingSocket::SendDatagram(const char* pch, int nSize, LPCSOCKADDR psa, int nSecs) const |
| 301 | { |
| 302 | ASSERT( pch != NULL ); |
| 303 | ASSERT( psa != NULL ); |
| 304 | ASSERT( m_hSocket!=INVALID_SOCKET ); |
| 305 | |
| 306 | fd_set fd; |
| 307 | FD_ZERO(&fd); |
| 308 | FD_SET(m_hSocket, &fd); |
| 309 | TIMEVAL tv = { nSecs, 0 }; |
| 310 | |
| 311 | // static_cast is necessary to avoid compiler warning under WIN32; |
| 312 | // This is no problem because the first parameter is included only |
| 313 | // for compatibility with Berkeley sockets. |
| 314 | if( _select(m_hSocket+1, NULL, &fd, NULL, &tv)==0 ) |
| 315 | { |
| 316 | throw CBlockingSocketException(_T("Send timeout")); |
| 317 | } |
| 318 | |
| 319 | const int nBytesSent = sendto(m_hSocket, pch, nSize, 0, psa, sizeof(SOCKADDR)); |
| 320 | if( nBytesSent==SOCKET_ERROR ) |
| 321 | { |
| 322 | throw CBlockingSocketException(_T("SendDatagram")); |
| 323 | } |
| 324 | |
| 325 | return nBytesSent; |
| 326 | } |
| 327 | |
| 328 | void CBlockingSocket::GetPeerAddr(LPSOCKADDR psa) const |
| 329 | { |
nothing calls this directly
no test coverage detected