MCPcopy Create free account
hub / github.com/demoth/jake2 / SendPacket

Method SendPacket

qcommon/src/main/java/jake2/qcommon/network/NET.java:150–170  ·  view source on GitHub ↗

Sends a Packet.

(int sock, int length, byte[] data, netadr_t to)

Source from the content-addressed store, hash-verified

148 * Sends a Packet.
149 */
150 public static void SendPacket(int sock, int length, byte[] data, netadr_t to) {
151 if (to.type == NetAddrType.NA_LOOPBACK) {
152 SendLoopPacket(sock, length, data, to);
153 return;
154 }
155
156 if (ip_sockets[sock] == null)
157 return;
158
159 if (to.type != NetAddrType.NA_BROADCAST && to.type != NetAddrType.NA_IP) {
160 Com.Error(Defines.ERR_FATAL, "NET_SendPacket: bad address type");
161 return;
162 }
163
164 try {
165 SocketAddress dstSocket = new InetSocketAddress(to.getInetAddress(), to.port);
166 ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket);
167 } catch (Exception e) {
168 Com.Println("NET_SendPacket ERROR: " + e + " to " + to.toString());
169 }
170 }
171
172 /**
173 * OpenIP, creates the network sockets.

Callers 2

transmitMethod · 0.95

Calls 5

SendLoopPacketMethod · 0.95
ErrorMethod · 0.95
PrintlnMethod · 0.95
getInetAddressMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected