开发者

Java Network / Socket programming tutorial [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with 开发者_开发技巧facts and citations.

Closed 5 years ago.

Improve this question

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:

  • Chapter 2. Basic Network Concepts
  • Chapter 3. Basic Web Concepts
  • Chapter 4. Java I/O
  • Chapter 5. Threads
  • Chapter 6. Looking Up Internet Addresses
  • Chapter 7. URIs and URLs
  • Chapter 9. Sockets for Clients
  • Chapter 10. Sockets for Servers

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.

Java Network / Socket programming tutorial [closed]


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.


There is no universal book for this kind of learning. The best bet is to start with java's own tutorial on sockets/threads etc here.

By encountering problems once you start the implementation it is then you will start learning, preferably by visiting SO again and asking a bunch of specific code questions.


from my experience and in my opinion, when you want to learn socket programming at the level of abstraction provided by the Java Network API and for any language for that matter, you also have to be familiar with i/o and threads. there are a lot of tutorials out there, i suggest you grab a book. just a thought!


If you want a simple, uncomplicated and easy-to-understand introduction to networking, I will strongly recommend that you read: Introduction to java programming 9th edtion by Liang Y. Daniel. Chapter 33 is networking, and chapter 32 is multithreading.

This book is very good. almost all i know in java, I got from that book. In that book, complex ideas are made very easy to understand. sorry i could not get the link for you. You can google it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜