Re: About JBC1.1b

From: Lars-Inge Tønnessen [VJ# MVP] (http://emailme.larsinge.com)
Date: 02/27/05


Date: Sun, 27 Feb 2005 19:39:22 +0100


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



Relevant Pages

  • Inconsistent behaviour on a network project.
    ... public class EmulatorTcpServer ... public void HandleCommand(Socket socket, string command) ... EmulatorTcpServer server = new EmulatorTcpServer; ... I'm having a problem with consistency depending on how I start the server... ...
    (microsoft.public.dotnet.languages.csharp)
  • Remoting and calling functions in another class
    ... server. ... I guess there is static functions, but I can't make everything in ... public class MyServer: MarshalByRefObject ... public void CalledByClient() ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Reloading and display images at runtime
    ... private JPanel btnpnl,picpnl; ... private ServerSocket server; ... public void paintPicture ... public class Buttonhandler implements ActionListener ...
    (comp.lang.java.gui)
  • Re: How to use generics?
    ... getting rid of the ACollection and BCollection and just having Collectionwould be a good start towards using generics to the full extent. ... public void AddCollection() ... public bool ContainsKey ...
    (microsoft.public.dotnet.languages.csharp)
  • program challenge
    ... public void setName{ ... the salaried class that extends Employee ... public class Salaried extends Employee ... // Programmer.java: the programmer class that extends from Hourly ...
    (comp.lang.java.help)

Loading