207 |
} |
} |
208 |
|
|
209 |
arr = (*env)->CallObjectMethod (env, packet, mid); |
arr = (*env)->CallObjectMethod (env, packet, mid); |
210 |
if ((arr == NULL) || (*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
211 |
|
return; |
212 |
|
if (arr == NULL) |
213 |
{ |
{ |
214 |
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call getData"); |
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call getData"); |
215 |
return; |
return; |
225 |
|
|
226 |
offset = (*env)->CallIntMethod (env, packet, mid); |
offset = (*env)->CallIntMethod (env, packet, mid); |
227 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
228 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, |
|
|
"Internal error: call getOffset"); |
|
|
return; |
|
|
} |
|
229 |
|
|
230 |
DBG ("PlainDatagramSocketImpl.receive(): Got the offset\n"); |
DBG ("PlainDatagramSocketImpl.receive(): Got the offset\n"); |
231 |
|
|
239 |
|
|
240 |
maxlen = (*env)->GetIntField (env, packet, fid); |
maxlen = (*env)->GetIntField (env, packet, fid); |
241 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
242 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call length"); |
|
|
return; |
|
|
} |
|
243 |
|
|
244 |
/* Receive the packet */ |
/* Receive the packet */ |
245 |
/* should we try some sort of validation on the length? */ |
/* should we try some sort of validation on the length? */ |
246 |
bytes_read = |
bytes_read = |
247 |
_javanet_recvfrom (env, obj, arr, offset, maxlen, &addr, &port); |
_javanet_recvfrom (env, obj, arr, offset, maxlen, &addr, &port); |
248 |
if ((bytes_read == -1) || (*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
249 |
|
return; |
250 |
|
if (bytes_read == -1) |
251 |
{ |
{ |
252 |
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: receive"); |
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: receive"); |
253 |
return; |
return; |
289 |
|
|
290 |
addr_obj = (*env)->CallStaticObjectMethod (env, addr_cls, mid, ip_str_obj); |
addr_obj = (*env)->CallStaticObjectMethod (env, addr_cls, mid, ip_str_obj); |
291 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
292 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, |
|
|
"Internal error: call getByName"); |
|
|
return; |
|
|
} |
|
293 |
|
|
294 |
mid = (*env)->GetMethodID (env, cls, "setAddress", |
mid = (*env)->GetMethodID (env, cls, "setAddress", |
295 |
"(Ljava/net/InetAddress;)V"); |
"(Ljava/net/InetAddress;)V"); |
301 |
|
|
302 |
(*env)->CallVoidMethod (env, packet, mid, addr_obj); |
(*env)->CallVoidMethod (env, packet, mid, addr_obj); |
303 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
304 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, |
|
|
"Internal error: call setAddress"); |
|
|
return; |
|
|
} |
|
305 |
|
|
306 |
DBG ("PlainDatagramSocketImpl.receive(): Stored the address\n"); |
DBG ("PlainDatagramSocketImpl.receive(): Stored the address\n"); |
307 |
|
|
315 |
|
|
316 |
(*env)->CallVoidMethod (env, packet, mid, port); |
(*env)->CallVoidMethod (env, packet, mid, port); |
317 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
318 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call setPort"); |
|
|
return; |
|
|
} |
|
319 |
|
|
320 |
DBG ("PlainDatagramSocketImpl.receive(): Stored the port\n"); |
DBG ("PlainDatagramSocketImpl.receive(): Stored the port\n"); |
321 |
|
|
329 |
|
|
330 |
(*env)->SetIntField (env, packet, fid, bytes_read); |
(*env)->SetIntField (env, packet, fid, bytes_read); |
331 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
332 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call length"); |
|
|
return; |
|
|
} |
|
333 |
|
|
334 |
DBG ("PlainDatagramSocketImpl.receive(): Stored the length\n"); |
DBG ("PlainDatagramSocketImpl.receive(): Stored the length\n"); |
335 |
#else /* not WITHOUT_NETWORK */ |
#else /* not WITHOUT_NETWORK */ |
355 |
|
|
356 |
netAddress = _javanet_get_netaddr (env, addr); |
netAddress = _javanet_get_netaddr (env, addr); |
357 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
358 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, |
|
|
"Internal error: get network address"); |
|
|
return; |
|
|
} |
|
359 |
|
|
360 |
DBG ("PlainDatagramSocketImpl.sendto(): have addr\n"); |
DBG ("PlainDatagramSocketImpl.sendto(): have addr\n"); |
361 |
|
|
362 |
_javanet_sendto (env, obj, buf, offset, len, netAddress, port); |
_javanet_sendto (env, obj, buf, offset, len, netAddress, port); |
363 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
364 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: send data"); |
|
|
return; |
|
|
} |
|
365 |
|
|
366 |
DBG ("PlainDatagramSocketImpl.sendto(): finished\n"); |
DBG ("PlainDatagramSocketImpl.sendto(): finished\n"); |
367 |
#else /* not WITHOUT_NETWORK */ |
#else /* not WITHOUT_NETWORK */ |
387 |
|
|
388 |
netAddress = _javanet_get_netaddr (env, addr); |
netAddress = _javanet_get_netaddr (env, addr); |
389 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
390 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, "Internal error"); |
|
|
return; |
|
|
} |
|
391 |
|
|
392 |
fd = _javanet_get_int_field (env, obj, "native_fd"); |
fd = _javanet_get_int_field (env, obj, "native_fd"); |
393 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
394 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, "Internal error"); |
|
|
return; |
|
|
} |
|
395 |
|
|
396 |
DBG ("PlainDatagramSocketImpl.join(): have native fd\n"); |
DBG ("PlainDatagramSocketImpl.join(): have native fd\n"); |
397 |
|
|
429 |
|
|
430 |
netAddress = _javanet_get_netaddr (env, addr); |
netAddress = _javanet_get_netaddr (env, addr); |
431 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
432 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, "Internal error"); |
|
|
return; |
|
|
} |
|
433 |
|
|
434 |
fd = _javanet_get_int_field (env, obj, "native_fd"); |
fd = _javanet_get_int_field (env, obj, "native_fd"); |
435 |
if ((*env)->ExceptionOccurred (env)) |
if ((*env)->ExceptionOccurred (env)) |
436 |
{ |
return; |
|
JCL_ThrowException (env, IO_EXCEPTION, "Internal error"); |
|
|
return; |
|
|
} |
|
437 |
|
|
438 |
DBG ("PlainDatagramSocketImpl.leave(): have native fd\n"); |
DBG ("PlainDatagramSocketImpl.leave(): have native fd\n"); |
439 |
|
|