| 1104 | } |
| 1105 | |
| 1106 | Net::Error Net::sendto(const NetAddress *address, const U8 *buffer, S32 bufferSize) |
| 1107 | { |
| 1108 | if(Journal::IsPlaying()) |
| 1109 | return NoError; |
| 1110 | |
| 1111 | SOCKET socketFd; |
| 1112 | |
| 1113 | if(address->type == NetAddress::IPAddress || address->type == NetAddress::IPBroadcastAddress) |
| 1114 | { |
| 1115 | socketFd = PlatformNetState::smReservedSocketList.resolve(PlatformNetState::udpSocket); |
| 1116 | if (socketFd != InvalidSocketHandle) |
| 1117 | { |
| 1118 | sockaddr_in ipAddr; |
| 1119 | NetAddressToIPSocket(address, &ipAddr); |
| 1120 | |
| 1121 | if (::sendto(socketFd, (const char*)buffer, bufferSize, 0, |
| 1122 | (sockaddr *)&ipAddr, sizeof(sockaddr_in)) == SOCKET_ERROR) |
| 1123 | return PlatformNetState::getLastError(); |
| 1124 | else |
| 1125 | return NoError; |
| 1126 | } |
| 1127 | else |
| 1128 | { |
| 1129 | return NotASocket; |
| 1130 | } |
| 1131 | } |
| 1132 | else if (address->type == NetAddress::IPV6Address || address->type == NetAddress::IPV6MulticastAddress) |
| 1133 | { |
| 1134 | socketFd = PlatformNetState::smReservedSocketList.resolve(address->type == NetAddress::IPV6MulticastAddress ? PlatformNetState::multicast6Socket : PlatformNetState::udp6Socket); |
| 1135 | |
| 1136 | if (socketFd != InvalidSocketHandle) |
| 1137 | { |
| 1138 | sockaddr_in6 ipAddr; |
| 1139 | NetAddressToIPSocket6(address, &ipAddr); |
| 1140 | if (::sendto(socketFd, (const char*)buffer, bufferSize, 0, |
| 1141 | (struct sockaddr *) &ipAddr, sizeof(sockaddr_in6)) == SOCKET_ERROR) |
| 1142 | return PlatformNetState::getLastError(); |
| 1143 | else |
| 1144 | return NoError; |
| 1145 | } |
| 1146 | else |
| 1147 | { |
| 1148 | return NotASocket; |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | return WrongProtocolType; |
| 1153 | } |
| 1154 | |
| 1155 | void Net::process() |
| 1156 | { |
nothing calls this directly
no test coverage detected