Performance and networking of Eclipse-run applet vs web applet - java

I have made a fairly simple turn-based multiplayer web game in an applet. My question is about the performance. I was noticing that there was a really long gap between a player taking his turn and the rest of the players seeing all the updates. It could be as long as 10 seconds for a single move/action.
The game runs on a dedicated server and all the players connect to the server as clients. As one player takes his turn, each move/action is sent to the server, and then from the server out to all the other clients. The server usually sends updates in the form of complete game-state objects, but also sends String messages. The client has a separate thread for listening for these updates. This is all done through a socket connection and persistent object input/output streams.
In my attempt to track down where the bottleneck is, I realized that if I run the applet from Eclipse (clicking "run as applet"), there is virtually no delay. So that means the client applets are sending out updates and the server is receiving them and then sending out it's updates perfectly. The bottleneck has to be in the applet's receiving/processing those updates.
I had two Chrome-applets and two Eclipse applets open on the same game. I would make a move on any of them and the two Eclipse applets would receive the server update instantly and the Chrome-applets would take as much as 10 seconds to get a single update.
Is there something import about different about how the applet runs in the browser vs in Eclipse? I know Eclipse is running the applet from local files, but doesn't a web-applet download all the appropriate files when it starts up? Thanks for your help. Let me know if posting some of my code would help.

Related

Viewing the same Applet on multiple clients

I have been trying to figure out how i would go about letting multiple clients view the same Applet on Java. I have the code for the the server and the clients and i have a program that I would like them to view. However whenever i test the code I end up with the clients seeing the same program but different instances of it. I want them both to be able to see the same program and see when the other clients make action on the Applet and what not. It would just be for a local connection and I don't have any HTML files at this time.

I'm trying to write a VNC server and client in java. I have a few questions

I want to write a VNC client and server as i think i will get to learn a lot. I would want to do this in JAVA however I saw somewhere that this isn't possible. I'd want to use C++ for parts that aren't possible in JAVA. I'm a little confused about where to begin. I saw TightVNC,RealVNC etc but the code base is too large for me to make sense. I see that the RFB specifies the packet types So could someone help me get started? How do I go about writing code to make the packet formats of any use? Also could anyone explain if this is a VNC server?
I have another question:
If i ditch RFB can i write
A server application: which basically captures everything on the screen and sends it to the client every few milliseconds. (Robot screencapture is too slow) And waits for mouse movements and keystrokes.
A client application that sends mouse movements and keystokes to the server and displays the screen of the server.
However I'm worried about synchornization.

Java applet socket server permissions

I want to make a Java applet, which functions as a socket server (local network ips, or 127 range is fine).
I want this applet to run in a webpage.
the browser can ideally load the webpage from the file system (file://...), but I could install an HTTP server if required.
The applet will need to be able to interact with JavaScript.
I'm having trouble wading through all the docs. Is the above possible? I'm not familiar with java's security model. If I need to sign the applet, or set some special security or configuration settings, that's fine.
edit-
In case anyones curious, the applet does very little. I just want to use it as a bridge so that another program running on the local computer can communicate via sockets. That program supplies values, which javascript will use to update the ui in real time. The ui is complicated, and building it in html/javascript will be a huge time saver. I'd prefer the applet function as the socket server opposed to a socket client, because otherwise then I need to write a seperate program to act as a server in between the applet and the other program.
Is the above possible?
Sure. If you control the security/policy files for that applet & the firewall, it is a single browser deal, it should be doable. You might need to wrap some of the applet methods in a PrivilegedAction if called from JS.

Java program blocking ports?

There is a program called PC^2 (a programming contest judging system). You can submit java files to it, and it will compile/run it.
I have a program that creates a socket, when I submit this to PC^2 it runs it fine, but I can't access the url (http://ip:port/) on my web browser. But when I quit PC^2 (my program is still running) it works when I hit refresh on my web browser. This means that PC^2 is somehow blocking the port, but not occupying it (i.e. making it's own ServerSocket that occupies the port) because if it was occupying it, then my program would have thrown an exception and quit.
What are possible ways that a Java program can do this? And since PC^2 is closed source, I can't look there.
Only one program at a time could listen to a certain port.
Same happens if you start tomcat twice using the some port
This has nothing to do with java. That is how sockets work
If PS^2 is running locally, you could check to see if it's listening before you run your program. I saw PS2 Version 9 uses sockets for communication, so perhaps that's what's going on? In Windows, these instructions will help confirm which process is listening on the ports. In linux, this page will help.

Screen scraping with Java and X3270

I have been trying to use Java to connect to X3270 (actually, wc3270, since I'm working on a windows environment) and control it to access a mainframe, login, navigate a few screens and get the data returned from x3270's command "ascii" for further processing (like separating the needed fields).
Even if I can connect to x3270 and login into the server, I'm having trouble to reliably retrieve the screens from x3270 after sending a command, even using threads to read the socket continuously.
Can anyone tell me what I should be doing to get things right?
I cannot more highly recommend Jagacy 3270, a Java screen scraping library that's incredibly reliable and dead easy to use. I had tried rolling my own, and also both IBM HATS and IBM Host on Demand, and found Jagacy to be easy, quick, lightweight, and already done for me.
A full license isn't cheap, but was worth it to us.

Categories

Resources