For Programmers: Free Programming Magazines  


Home > Archive > Java Security > April 2005 > Create custom socket









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Create custom socket
Thanh

2005-04-06, 12:27 pm

Hi all,

I am trying to call Java SSL within a C program via JNI. The
constraints/requirements are:

1) The socket is created inside the C program. Bound to a port but no
accept() has been called yet.
2) The socket descriptor is passed via the JNI
3) Java code will create a SSLServerSocket type socket based on this
descriptor. (ideally resuse the existing on created in C instead of
creating additional socket using same descrptor)

Does anyone know how 3) can be done?



Thanks,

kjc

2005-04-06, 12:27 pm

Thanh wrote:
> Hi all,
>
> I am trying to call Java SSL within a C program via JNI. The
> constraints/requirements are:
>
> 1) The socket is created inside the C program. Bound to a port but no
> accept() has been called yet.
> 2) The socket descriptor is passed via the JNI
> 3) Java code will create a SSLServerSocket type socket based on this
> descriptor. (ideally resuse the existing on created in C instead of
> creating additional socket using same descrptor)
>
> Does anyone know how 3) can be done?
>
>
>
> Thanks,
>

Descriptors have no meaning outside the OS.
Similiar to a pointer.
Thanh

2005-04-06, 12:27 pm

I guess you are saying there's no way. But I saw SocketImpl has a
private field called 'fd'. Can't I do something to set it to the one
created in the C code? If so, how to set it? and how to associate this
SocketImpl object to the SSLServerSocket?


kjc wrote:
> Thanh wrote:
no[color=darkred]
this[color=darkred]
> Descriptors have no meaning outside the OS.
> Similiar to a pointer.


kjc

2005-04-06, 12:27 pm

Thanh wrote:
> I guess you are saying there's no way. But I saw SocketImpl has a
> private field called 'fd'. Can't I do something to set it to the one
> created in the C code? If so, how to set it? and how to associate this
> SocketImpl object to the SSLServerSocket?
>
>
> kjc wrote:
>
>
> no
>
>
> this
>
>
>

You'll have an int value for the fd, but, it will mean nothing to the OS
on the machine that is attemping the connection. Since it was not
allocated on that machine.

I don't understand why you really need to do this. What it sounds like
you want to do is pass in the port number via JNI.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com