TCP / IP Java Network Programming from the Basics, Ohmsha, Tomohiro Odaka, 1999.8
https://www.amazon.co.jp/dp/4274064867/ It has been used as a teaching material for JAVA training since the year the first edition was published. The second edition (URL above) was released in 2002. Before reaching this book, I entered the sources of 20 books (or compiled them on the CD). The advantage of this book over other books is that you can experience how easy it is to operate the network, which is a specialty of JAVA.
In 1996, I practiced JAVA and Microsoft J ++ from Sun Microsystems in another book. Since 1999, I have practiced with JBuilder in this book. Some of us have taken this book and completed three-digit exercises, and now there are those who teach at universities and companies.
This time, we will use Eclipse's Java Developer tools.
Understand basic communication conventions such as TCP, IP, UDP, and HTTP. In addition, it is good to check the operation while acquiring data with software called Wireshark that monitors packets.
http://wireshark.org The wireshark source code may also be used in various communication devices. Details at the end of this article.
Windows https://www.eclipse.org Download Eclipse from. After downloading Select "Eclipse Java Developer tools" and install it additionally. If you don't make this selection, you can compile, but you may get an execution error.
Macintosh Introducing Eclipse to Macintosh OS X (5 walls) https://qiita.com/kaizen_nagoya/items/b17f03db00aceee41a80
Debian/Ubuntu/Raspbian
apt-get update
apt-get install eclipse
Select "Java Project" from "New" in the "File" menu.
If it is 2.2.1 Readnet, enter "Readnet" in "Project Name". When "Finish" becomes selectable, press "Finish".
If the "Java Project" does not appear, it means that the introduction of "Java developer tools" has not been successful. I will try to introduce it again.
Select "class" of "New" from the "File" menu.
Enter "readnet" and "Readnet" in "Package:" and "Name:". When "Finish" becomes selectable, press "Finish".
If you capitalize the Package name as "Readnet", the following warning will appear under "Java Class" at the top. 「This package name is discouraged. By convention, package names usually start with a lowercase letter」
Rednet.java
package readnet;
public class Readnet {
}
Make sure the file name and class name are the same. Java assumes one class definition in one file. Therefore, if the file name and class name are different, a compile error will occur.
Select "Run Configurations" from the "Run" menu.
Double-click Java Application. Select the "(x) = Arguments" tab, enter the required parameters in "Program arguments:", and press "Run".
For example, as a usage in the P88 "2.2 Network Functions Available in JAVA" program
//Example JAVA Readnet kick.fuis.fukui-u.ac.jp 60000
It has become. Here, enter the environment you are using. For example, if 192.168.2.23 is an IP address, you may enter the IP address directly. Also, even if the port number is 60000, you can use another available number to deal with the other party.
In C language, the program name is entered in args [0], but in JAVA, the first argument is entered in args [0].
You will be asked if you want to save the file. Press "OK".
Run-time errors or program results appear in the "Console".
If there is a compilation error, it will be displayed in the "Problems" tag.
At first, a compile error appears 2-3 times due to a description error, and I remember it while fixing it.
There is a compilation error, but if you want to proceed, select "Proceed", and if you want to go back and fix it and compile again, select "Cancel".
The "Package Explorer", the line number of the source code, and the "Outline" also show the location of the compilation error. If you select the "Problems" tag, you will see a list of compilation errors. If there are more than one error
If the execution result is not what you expected, Start wireshark and measure packets. When interacting with other network devices, select the interface to which they are connected. For example, "Ethernet: en0". If you want to interact with yourself, select "Loopback: lo0".
To avoid this, on Macintosh and Linux, use the command prompt.
su otheruser
wireshark &
Select "Loopback: lo0". Here, other user is the ID of another user. Even if you type otheruser, it is said that you do not know that there is no person with the ID otheruser.
You can measure packets from yourself to yourself.
Windows https://www.wireshark.org/download.html
Windows Installer (64-bit)
Windows Installer (32-bit)
Drop one of them and execute.
Macintosh Five Walls to Introduce Wireshark to Macintosh https://qiita.com/kaizen_nagoya/items/69eb2d357a125f5368e1 reference
Debian/Ubuntu/Raspbian
apr-get update
apt-get install wireshark
https://qiita.com/kaizen_nagoya/items/b3fa0a20855d44c3768d
1 The Class name and file name are the same, and the extensions are class and java, respectively. Project and Package may be the same. However, in principle, Package starts with a lowercase letter. 2 Good at Internet (compared to C and C ++ languages before JAVA) There is a main function in 3 classes. A feeling of strangeness. It may be good to have the main class as the main class or the OS class of the execution environment. 4 In C language, args [0] is the program name. In JAVA, the first argument is entered in args [0].
1 Eclipse is also written in JAVA and is compatible. 2 Introduced JAVA Developer tools 3 Start with New-> Java Project, New-> class. 4 For command arguments, select the "(x) = Arguments" tab and the parameters required for "Program arguments:".
1 Use Wireshark 2 Specify Loopback as the interface for packets to yourself 3 If access is prohibited, su to an accessible person and start with wireshark & 4 For connections other than yourself, select a specific connection such as Ethernet: en0.
This article is about to be written. I will add it one by one.
"TCP / IP JAVA network programming understood from the basics" Chapter 2 Network programming by JAVA phttpd Exception collection in three places
https://qiita.com/drafts/d1db78d3db0e90c0ff9f
It is said that I don't like it because it is http / 0.9.
Passed the Information-Technology Engineers Examination Network Specialist https://qiita.com/kaizen_nagoya/items/407857392ca5c5677ee4
Communication emulator port https://qiita.com/drafts/ce505bbea4229b83e93b
Macintosh compatible "TCP / IP analyzer creation and packet analysis understood from the basics Linux / FreeBSD compatible" Tomohiro Odaka Ohmsha https://qiita.com/kaizen_nagoya/items/517411b42fc5ceabd581
Recommended Posts