5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ソケットタイプとは

Last updated at Posted at 2021-11-26

はじめに

個人的まとめ。ソケットタイプとは、プロセス(ソケット)の通信方式を指定するものである。

ソケットタイプの種類

Stream sockets

  • TCPを使った通信
  • ソケットタイプはSOCK_STREAM

Datagram sockets

  • UDPを使った通信
  • ソケットタイプはSOCK_DGRAM

Raw sockets

  • ICMPへのアクセスを提供
  • 通常のアプリケーションが使用するものではなく,新たなプロトコルの開発や新たなプロトコルの機能の開発の際に使われるもの
  • ソケットタイプはSOCK_RAW

ストリームとデータグラムの違い

ストリーム通信はTCPによって、データグラム通信はUDPによって行われる。

TCPはスリーウェイハンドシェイクによって、クライアント・サーバー間のコネクションを確保してからデータの送受信を行う。クライアント・サーバー間にデータの流れ(Stream)ができるのでストリーム通信と呼ばれる。

対してUDPはクライアント・サーバー間のコネクションを確保せずに一方的にデータを送りつける形なので、送信したいデータを制御情報等を付加された一定程度の大きさのデータの塊(データグラム)に分割して送信することからデータグラム通信と呼ばれる。

参考

Socket Types (Network Interface Guide)

5
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?