Daniel Zuckermann

Ranch Hand
+ Follow
since May 14, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
38
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Daniel Zuckermann

Thank you, sheriff. Ok, InputStream and OutputStream read and write pure bytes and are most flexible. There are many wrapper classes, e.g. Object-I/O-Stream, Buffered-I/O-Stream, Checked-I/O-Stream, Cipher-I/O-Stream and Data-I/O-Stream but as far as I know they are all Java-specific. For this reason I can't write data to a stream like this and send it to a C++ socket:


Is my understanding correct? My goal is just to send some simple data from a Java socket to a C++ socket and vice versa and for the sake of simplicity I want to encode numbers as text, so I don't have to deal with any number representation issues.
What is important if one wants to send data between a Java socket and a socket that is written in another language, maybe C++? Of course I can't use any classes that write Java-specific code into the stream and I must also define a charset that sender and receiver use. At the beginning it would be sufficient to use text data, so I don't have to care about number representation.
Which Java classes can be used to communicate with sockets that don't use Java?
Thanks. I know that Void is a reference to void and therefore null can be returned as an object.

What I was trying to do is making Collable's call method return different types depending on what kind of value is given to the Callable constructor. In the call method a switch statement shall check a condition and then execute some code. Depending on the case, null or another value (String, Integer, Collection...) is returned.

I know that is possible, but in this case I could also implement Runnable and call run.

Maybe I have found out the answer by myself:
Callable<Void> is used to make sure that the function returns absolutely nothing, but any other parametrization like Callable<Number> implicitly allows to return null which is the "Void object".


4 years ago
Hello,
I'm wondering if it is somehow possible to make a generic function that returns Void (the object) or an other value like a String or Integer.

Thanks for your input.
4 years ago
Hello people,
I am not sure how I could serialize objects to send them over the internet from one Java NIO client socket to a Java NIO server socket. NIO sockets read from buffers, so I have to serialize the objects before and then somehow read them into the buffer. How does this work?
Thanks for your help. A database would be overkill, because this is just for learning purposes. I tried to avoid server-side code, because I wanted to test the code outside on a remote server, but there I can't start a Java server script. For this reason, I decided to test it locally by using the ServerSocketChannel class, which supports multithreading. The client sends a message (name and score) to the server and the server attaches this data to a XML file. However, I am not sure if I should send simple messages or better use objects, that wrap username and score. I would prefer the 2nd option and use XMLEncoder to store those objects in a XML file. When the client requests the higscore list, the server sends the whole list or maybe ten of the best players. Does this sound coherent?

Yes, the update mechanism must support multithreading, which can't be implemented without using any server side script. What do you guys think about the options I have mentioned?
I don't try to avoid a 3rd part library.

What I want to accomplish is a simple, yet reliable highscore list without using a database. There are multiple options to achieve that goal: RMI, sockets and the Apache library. The users and their scores could be stored in a XML file.
No, I'm just wondering if there isn't any solution to this problem from the java.net library, because I searched quite a long time, but didn't find one. However, Apache Commons Net seems to be a very easy solution, so I will stick to that. Thanks for your help.
Thanks, that looks very promising. Do I have any other options, maybe from java.net.* without using an external library?
I just want to rent some webspace, so I own the webspace and can upload and access data, but I don't own the complete server. On this personal webspace, I want to store a file that I can download from within a Java program, write on this file and then store the file again on the server.
I'm using a server that I don't own, so I have limited access, but instead of entering password and username manually to access a website on this server, I want the client Java program to do that. I will use the protocol that is easiest to handle.
I just want to prevent that an unauthorized person reads and writes the remote file. Hence, I need something like password protection and maybe also encryption. So the Java client has to submit username and password and encrypt and decrypt the file.
Hello all,
I would like to store a file on a remote server that should be read and be written on from multiple clients, but I don't know exactly how to secure this file. On the server side I could make it accessible only from certain IP addresses, but what could be done on the Java-based client side? Maybe storing the file encrypted?
Thanks for any help.
Hello people,
I am trying to build a very simple and basic 2D game where the main focus lies on good architecture. I would like to implement it as a state machine with at least the following states:
- running
- paused
- stopped

However, more states could make sense, but I don't know which function calls or behaviors should be modeled as new states. Example: While the game is running, the user clicks on the settings panel to change some settings. Do I need a new state here or would the game just switch to the "paused" state? Would it be a better idea to disable the settings panel while the game is running?
Can every GUI view be seen as a new state or would that be overkill?

I am not sure if a concrete state should better be a subclass of an abstract state class or implement a state interface. It could also be interesting to save the game state persistently in a file so that the game can be resumed after rebooting the machine, but I don't know how complicated this is and if there is some kind of helper API out there.
4 years ago