вторник, 13 мая 2014 г.

Типы сокетов

  SOCK_STREAM
          Provides sequenced,  reliable,  two-way,    connection-based  byte
          streams.    An out-of-band data transmission mechanism may be sup-
          ported. (потоковый сокет)

       SOCK_DGRAM
          Supports datagrams (connectionless,  unreliable  messages     of  a
          fixed maximum length). (датаграммный сокет)

       SOCK_SEQPACKET
          Provides    a  sequenced,  reliable, two-way connection-based data
          transmission path for datagrams of fixed maximum length; a  con-
          sumer is required to read an entire packet with each read system
          call. (надёжная служба последовательных пакетов)

       SOCK_RAW
          Provides raw network protocol access.

       SOCK_RDM
          Provides a reliable  datagram  layer  that  does    not  guarantee
          ordering.

       SOCK_PACKET
          Obsolete    and should not be used in new programs; see packet(7).

Basically SOCK_DGRAM is used for UDP packets, SOCK_STREAM for TCP 


Указатели протоколов создаваемого сокета

These constants represent the address (and protocol) families, used for the first argument to socket():

socket.AF_UNIX - локальных сокетов (адрес определяется как строка, содержащая путь в файловой системе /etc/tmp).
socket.AF_INET
- для сетевого протокола IPv4 или
socket.AF_INET6
- для сетевого протокола IPv6


If the AF_UNIX constant is not defined then this protocol is unsupported.

unix, AF_UNIX, AF_LOCAL - Sockets for local interprocess communication

The difference is that an INET socket is bound to an IP address, while a UNIX socket is "bound" to a special file on your filesystem -- only processes having access to that filesystem (i.e. running on the same machine) can communicate through the latter.

http://manpages.ubuntu.com/manpages/lucid/man7/unix.7.html
http://unixhelp.ed.ac.uk/CGI/man-cgi?socket+2

Комментариев нет:

Отправить комментарий