Yeah,I have seen it before.
But In applet I could make a TCP Socket connection to the same site where
applet was downloaded from.
I converted my applet to J# Browser Controls,
but it gives me a SecurityException at runtime.
Thank you for your reply.
Sounds like a configuration problem. I have just tested a socket connection
from a JBC to the server the JBC was loaded from. It's working for me.
Please check the "J# Browser Security control" in the "Administrative tools"
in the Control Panel.
In the "Microsoft .NET Framework 1.1 wizard shotcut", "Adjust .NET
security", "make changes for this computer", "next"choose "Full Trust" for
the site/internet option.
My test example:
The "index.html" file:
<HTML>
<BODY>
<OBJECT CLASSID="clsid:a399591c-0fd0-41f8-9d25-bd76f632415f"
WIDTH=300 HEIGHT=110
ID=Go
VJSCODEBASE = "JBC_Socket.dll#Go" >
</OBJECT>
</BODY>
</HTML>
The JBC "Go.java"
This is a J# Class library project.
public class Go extends java.applet.Applet
{
public void init( )
{
try
{
java.net.Socket socket = new java.net.Socket( "localhost", 4566 );
String message = "I'm a client";
String receivedMEss = "";
java.io.DataOutputStream out = new java.io.DataOutputStream(
socket.getOutputStream() );
out.writeBytes( message );
java.io.BufferedReader reader = new java.io.BufferedReader( new
java.io.InputStreamReader( socket.getInputStream() ) );
receivedMEss = reader.readLine();
this.add( new java.awt.Label( receivedMEss ) );
}
catch ( Exception e ) { }
}
public void paint( java.awt.Graphics g )
{
this.setBackground( java.awt.Color.black );
this.setForeground( java.awt.Color.white );
g.drawLine( 0,0, 50, 50 );
}
}
The socket server :
public class Class1
{
public Class1()
{
System.Net.Sockets.TcpListener listener = new
System.Net.Sockets.TcpListener( 4566 );
listener.Start();
System.Net.Sockets.TcpClient client = listener.AcceptTcpClient();
System.Net.Sockets.NetworkStream strem = client.GetStream();
ubyte byt[] = new ubyte[2048];
strem.Read( byt, 0, 1000 );
String s = System.Text.Encoding.get_ASCII().GetString(byt, 0, 1000);
System.Console.WriteLine( "->" + s );
ubyte[] out = System.Text.Encoding.get_ASCII().GetBytes("Hello back");
strem.Write( out, 0, out.length );
strem.Close();
}
/** @attribute System.STAThread() */
public static void main(String[] args)
{
new Class1();
}
}
Regards,
Lars-Inge T?nnessen
mela mela - 28 Feb 2005 12:13 GMT
Oh~thx~
I could connected now,but that sounds odd.
It said in the second level of trust for assemblies
the program can connected back to their site of origin.
But it just works when I choose fulltrust.@@
Thank you for your reply^^