I'm going to create a project in some month in a course I'm having and for that purpose I would like to read and try making some small test programs regarding the network / socket programming in Java.
Ideally, what I'm looking for is a tutorial with description and a end program to create where I can between two computers send and resive small and simple text messages. Don't have to be any GUI or something like that just the simple version.
I've read some articles from Sun's own homepage and in one of my Java Book but I seem to be missing the last piece of the puzzle to really understand that "network programming".
In addition, I don't know if I'm mixing things now but to my understanding can the multithreading paradigm also be applied to the network / socket programming.
Therefore, my question is, if anyone knows about a good tutorial or educational link for me to get an overview of this topic. I’m not totally new to Java but haven’t got any experience in this type of programming.
Thanks - Emil
Here is a nice sample chapter from Java Network Programing. There's also some other parts available here, and also sample sources are available.
If you'd decide to buy this book, I'd say these chapters are enough for now:
Don't bother about NIO yet; it's quite advanced.
In addition, I don't know if I'm mixing things now but to my understanding can the multithreading paradigm also be applied to the network / socket programming.
Yes, indeed it's a very important aspect. You'll find out why once you've read the sample chapter.
Have fun!
I've only read the C version of this book, but likely Java version is going to be equally short and good: Calvert and Donahoo's TCP/IP Sockets in Java: Practical Guide for Programmers. Even if you learned socket programming in C, you could probably adapt to Java's implementation fairly quickly.
For basic steps you might wan't to read this tutorial Sockets programming in Java. In this model the most people used one thread to handle one network connection.
In java 1.4 NIO was introduced, this makes intros a bit more complex: Java NIO Tutorial.
NIO allows to use a Selector which allows you to handle many connections in one thread, which leads to higher performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With