I want to make an application that communicates over the network in java. Just something that I can give to someone else and we can send information back and forth given an IP address. What are some good online tutorials for me to look at?
>>3
Thanks, this looks like a good starting point.
Name:
Anonymous2011-12-26 11:03
Every language have sockets, 99% of them have simpler socket handling than Java's reader objects inside reader objects fetish, half of your toy instant messenger will be threading boilerplate to handle sending and receiving, if its really "just something" you'll be wasting time setting up and rewriting types everywhere in a language when a dynamic typing language was sufficient. When most of the scripting languages have exe bundlers to make it easy to deploy, why Java? IHBT
>>6
I picked java because I'm already familiar with swing and I figured java would be simpler and have a lot of documentation. What would you suggest? I know c, c++, and python too. Would those be any better?
Name:
Anonymous2011-12-26 11:15
>>6
Almost every language *supports* sockets. The difference between the two. Cripes now I see why you don't work as a programmer for a living.
>>8
If you can't figure out where to look for information on sockets, then you don't really know Java, C++ or Python. Seriously.
Name:
Anonymous2011-12-26 14:34
>>14
Looking for information on sockets is not a programming language issue. The fact that you think it is just shows that you're a mental midget with no real possible future as a computer programmer.
Name:
6,132011-12-26 15:22
(more serious response, FITINT)
Since its a personal project without deadlines or the enterprise-tier stress, you could try something different. Many Lisps do have fairly easy windowing libraries at least, and there's Clojure if you want to use the JVM.
Anyway, no matter the language, to do what you want to do you'll have to first decide if it will be UDP or TCP. In both cases you have senders and listeners, and each others' address and port.
If you choose UDP both sides have to listen for UDP, usually this involves calling a udp-listen function and that either returns if its non-blocking, or it writes to a pre-allocated array you've provided for a single packet (in many of the languages I've seen this is norm, even Lisps like Racket). UDP sending functions returns right away and uses the same pre-allocated array stuff.
If you choose TCP, and it is a TCP session that stays on, you'll have to have one who connects and one who listens/accepts for the connection. The connecting part is a function call to connect to a name and port that blocks and then returns a either a single or a tuple of file-like handles in most languages which you then treat like a console, send lines, receive lines. The listening part (in blocking mode) will wait until a connect requests happens and returns an object which you then accept with a second command which then returns the same type of file handles, from here on it is the same as the connect part. Like file operations and unlike UDP you'll have to sometimes flush the file handles to get the packets out.
You'll have to contend with concurrency in some way with either some periodic non-blocking reads to the socket by using some sort of timer event like WM_TIMER and the various platforms' version of these intervaled invocations, or blocking reads in a dedicated thread. Generally, the non-blocking reads may be adequate but if the timed check is not frequent and the volume of data is enough the socket may collapse from a buffer overrun.
Since this is ``peer to peer technology'' you'll may have to contend with firewhales and NATs, but other than that you just find out their IP address and port and do the above.
danger, danger >>8-san, >>6,11-san is trying to pull you over to the Lispth side! You may find static typing and class declarations annoying and verbose, but beware the lisp side. The succinctness may seduce you, but if you give in, forever will it dominate your destiny.
You must travel to the oracle website in your webrowser. There you will begin your training. Your first task will be to create a java echo client and server, where the server sends ascii to the client and the client prints the ascii to the screen. This is the first step on your path to becoming an enterprise java web application engineer! But beware the lisp side. Do not give in to the temptation of saving key strokes, or suffer the same fate as >>6,11, you will.
Name:
Anonymous2011-12-26 20:19
ohh yeah common lisp does this easily with GUI via McClim.
maybe try ABCL if you _HAVE_ to use JVM.
Try cl-irc and beirc for some code.
You can't get a job using Java so forget that crap.
>>19
Sure in the last 10 years Clojure is the "most well thought-out" language and the better "java" but compared to Common Lisp the "most well thought-out" language ever it is nothing.
The object model alone would never make a person who values sanity use "the Java" even with Clojure.
Aside from the "javaness" shitting up a Lisp, Clojure, it is nice to see more people coming closer than half way to lisp.