| 75 | } |
| 76 | |
| 77 | int UdpShortConn::CreateSocket() |
| 78 | { |
| 79 | _osfd = socket(AF_INET, SOCK_DGRAM, 0); |
| 80 | if (_osfd < 0) |
| 81 | { |
| 82 | MTLOG_ERROR("socket create failed, errno %d(%s)", errno, strerror(errno)); |
| 83 | return -1; |
| 84 | } |
| 85 | |
| 86 | int flags = 1; |
| 87 | if (ioctl(_osfd, FIONBIO, &flags) < 0) |
| 88 | { |
| 89 | MTLOG_ERROR("socket unblock failed, errno %d(%s)", errno, strerror(errno)); |
| 90 | close(_osfd); |
| 91 | _osfd = -1; |
| 92 | return -2; |
| 93 | } |
| 94 | |
| 95 | if (_ntfy_obj) { |
| 96 | _ntfy_obj->SetOsfd(_osfd); |
| 97 | } |
| 98 | |
| 99 | return _osfd; |
| 100 | } |
| 101 | |
| 102 | int UdpShortConn::CloseSocket() |
| 103 | { |
nothing calls this directly
no test coverage detected