ドメイン名
| 日本語 | 領域名 |
| 英語 | domain name |
| ふりがな | どめいんめい |
| フリガナ | ドメインメイ |
インターネット上でホストに付けられた「名前」。
たとえば「yahoo.co.jp」という文字列が「ドメイン」もしくは「ドメイン名」と呼ばれるものである。
ドメイン名は「IPアドレスを検索するための名前」である。
ドメイン名はICANNによって管理されており、世界各国のDNSサーバーに「どのドメイン名がどのIPアドレスと結び付けられているか」が記録されている。
ドメイン名を元に接続を行う場合、DNSに「ドメイン名に対応するIPアドレス」を尋ね、そのIPアドレスで接続する。つまり、実際の接続はIPアドレスを用いて行われている点に注意。
ドメイン名は「苗字」が連なってできている。
右端が一番大きな苗字である。「jp」等の国を示すものや、「com」「org」といった組織の種類を示すものが付けられる。
jpドメイン名の場合、その次に組織の種類が来る。「co」は企業、「ne」はプロバイダ等ネットワーク関係の組織となる。
その次に、実際のホストの「名前」が来る。「yahoo」「kab-studio」等がそうである。
これらに加えて、もうひとつ名前が付けられる場合も多い。「www.yahoo.co.jp」の「www」の部分である。これは通常プロトコルを区別するために付けられるが、ない場合と同じIPアドレスの場合も多い。また、この部分の名前はICANNでは管理されない、ローカルな名前となっている。
Javaのプログラムでは、多くの場合ホスト名としてドメイン名を指定すると、自動的にIPアドレスに変換して使用するため、特に「ドメイン名を使用している」ということを意識する必要はないだろう。
たとえば「yahoo.co.jp」という文字列が「ドメイン」もしくは「ドメイン名」と呼ばれるものである。
ドメイン名は「IPアドレスを検索するための名前」である。
ドメイン名はICANNによって管理されており、世界各国のDNSサーバーに「どのドメイン名がどのIPアドレスと結び付けられているか」が記録されている。
ドメイン名を元に接続を行う場合、DNSに「ドメイン名に対応するIPアドレス」を尋ね、そのIPアドレスで接続する。つまり、実際の接続はIPアドレスを用いて行われている点に注意。
ドメイン名は「苗字」が連なってできている。
右端が一番大きな苗字である。「jp」等の国を示すものや、「com」「org」といった組織の種類を示すものが付けられる。
jpドメイン名の場合、その次に組織の種類が来る。「co」は企業、「ne」はプロバイダ等ネットワーク関係の組織となる。
その次に、実際のホストの「名前」が来る。「yahoo」「kab-studio」等がそうである。
これらに加えて、もうひとつ名前が付けられる場合も多い。「www.yahoo.co.jp」の「www」の部分である。これは通常プロトコルを区別するために付けられるが、ない場合と同じIPアドレスの場合も多い。また、この部分の名前はICANNでは管理されない、ローカルな名前となっている。
Javaのプログラムでは、多くの場合ホスト名としてドメイン名を指定すると、自動的にIPアドレスに変換して使用するため、特に「ドメイン名を使用している」ということを意識する必要はないだろう。
参考サイト
// Sample.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;
public class Sample
{
public static void main( String[] args )
{
BufferedReader bufferedReader = null;
HttpURLConnection httpURLConnection = null;
try
{
// プロトコル。
String protocol = "http";
// ホストを示すドメイン名。
String host = "yahoo.co.jp";
// ポート番号。
int port = 80;
// ファイルパス。
String filePath = "/index.html";
// アクセスするためのURLクラスを作ります。
URL url = new URL( protocol, host, port, filePath );
System.out.println( url.toString() );
// http://www.yahoo.co.jp:80/index.html
// Content-Typeの文字コード(注:実際には、HEADで文字コードを取得してから指定します)。
String charSet = "EUC-JP";
// リクエストのメソッド。
String method = "GET";
// 指定されたURLを元にリクエストを発行します。
httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod( method );
// リクエストの結果を取得します。
InputStreamReader inputStreamReader = new InputStreamReader( httpURLConnection.getInputStream(), charSet );
bufferedReader = new BufferedReader( inputStreamReader );
// 全行出力します。
while( true )
{
String oneLine = bufferedReader.readLine();
if( oneLine == null )
{
break;
}
System.out.println( oneLine );
}
// <html>
// <head>
// <title>Yahoo! JAPAN</title>
// (以下略)
}
catch( IOException e )
{
e.printStackTrace();
}
finally
{
if( bufferedReader != null )
{
try
{
bufferedReader.close();
}
catch( IOException e )
{
e.printStackTrace();
}
}
if( httpURLConnection != null )
{
httpURLConnection.disconnect();
}
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;
public class Sample
{
public static void main( String[] args )
{
BufferedReader bufferedReader = null;
HttpURLConnection httpURLConnection = null;
try
{
// プロトコル。
String protocol = "http";
// ホストを示すドメイン名。
String host = "yahoo.co.jp";
// ポート番号。
int port = 80;
// ファイルパス。
String filePath = "/index.html";
// アクセスするためのURLクラスを作ります。
URL url = new URL( protocol, host, port, filePath );
System.out.println( url.toString() );
// http://www.yahoo.co.jp:80/index.html
// Content-Typeの文字コード(注:実際には、HEADで文字コードを取得してから指定します)。
String charSet = "EUC-JP";
// リクエストのメソッド。
String method = "GET";
// 指定されたURLを元にリクエストを発行します。
httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod( method );
// リクエストの結果を取得します。
InputStreamReader inputStreamReader = new InputStreamReader( httpURLConnection.getInputStream(), charSet );
bufferedReader = new BufferedReader( inputStreamReader );
// 全行出力します。
while( true )
{
String oneLine = bufferedReader.readLine();
if( oneLine == null )
{
break;
}
System.out.println( oneLine );
}
// <html>
// <head>
// <title>Yahoo! JAPAN</title>
// (以下略)
}
catch( IOException e )
{
e.printStackTrace();
}
finally
{
if( bufferedReader != null )
{
try
{
bufferedReader.close();
}
catch( IOException e )
{
e.printStackTrace();
}
}
if( httpURLConnection != null )
{
httpURLConnection.disconnect();
}
}
}
}
// Sample.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;
public class Sample
{
public static void main( String[] args )
{
BufferedReader bufferedReader = null;
HttpURLConnection httpURLConnection = null;
try
{
// プロトコル。
String protocol = "http";
// ホストを示すドメイン名。
String host = "yahoo.co.jp";
// ポート番号。
int port = 80;
// ファイルパス。
String filePath = "/index.html";
// アクセスするためのURLクラスを作ります。
URL url = new URL( protocol, host, port, filePath );
System.out.println( url.toString() );
// http://www.yahoo.co.jp:80/index.html
// Content-Typeの文字コード(注:実際には、HEADで文字コードを取得してから指定します)。
String charSet = "EUC-JP";
// リクエストのメソッド。
String method = "GET";
// 指定されたURLを元にリクエストを発行します。
httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod( method );
// リクエストの結果を取得します。
InputStreamReader inputStreamReader = new InputStreamReader( httpURLConnection.getInputStream(), charSet );
bufferedReader = new BufferedReader( inputStreamReader );
// 全行出力します。
while( true )
{
String oneLine = bufferedReader.readLine();
if( oneLine == null )
{
break;
}
System.out.println( oneLine );
}
// <html>
// <head>
// <title>Yahoo! JAPAN</title>
// (以下略)
}
catch( IOException e )
{
e.printStackTrace();
}
finally
{
if( bufferedReader != null )
{
try
{
bufferedReader.close();
}
catch( IOException e )
{
e.printStackTrace();
}
}
if( httpURLConnection != null )
{
httpURLConnection.disconnect();
}
}
}
}




