f



Create custom socket

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,

0
4/5/2005 10:05:47 PM
comp.lang.java.security 1502 articles. 0 followers. Post Follow

3 Replies
437 Views

Similar Articles

[PageSpeed] 28

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.
0
kjc
4/5/2005 11:45:33 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:
> > 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.

0
Thanh
4/6/2005 1:41:57 AM
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:
> 
>>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.
> 
> 
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.
0
kjc
4/6/2005 1:58:25 AM
Reply: