Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the function of SOCK_STREAM?

I am learning about sockets in Python and came up with

variable = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

I understood the function of this socket.socket and socket.AF_INET but I am curious about socket.SOCK_STREAM. What is its function?

like image 235
Shashank Pulijala Avatar asked Mar 01 '16 14:03

Shashank Pulijala


People also ask

What is the use of Sock_stream?

In the Internet domain, the SOCK_STREAM socket type is implemented on the Transmission Control Protocol/Internet Protocol (TCP/IP) protocol. A stream socket provides for the bidirectional, reliable, sequenced, and unduplicated flow of data without record boundaries.

What is Sock_stream in Python?

SOCK_STREAM means that it is a TCP socket. SOCK_DGRAM means that it is a UDP socket. These are used 99% of the time. There are other possibilities as well, see https://docs.python.org/2/library/socket.html#socket.SOCK_STREAM (you will have to google for the meaning of each one).

What is characteristic of Sock_dgram?

SOCK_DGRAM : Provides datagrams, which are connectionless messages of a fixed maximum length. This type of socket is generally used for short messages, such as a name server or time server, because the order and reliability of message delivery is not guaranteed.

What is socket Af_inet Sock_stream?

s = socket(AF_INET, SOCK_STREAM, 0); This call results in a stream socket with the TCP protocol providing the underlying communication. The following creates a datagram socket for intramachine use: s = socket(AF_UNIX, SOCK_DGRAM, 0); Use the default protocol (the protocol argument is 0) in most situations.


2 Answers

SOCK_STREAM means that it is a TCP socket.

SOCK_DGRAM means that it is a UDP socket.

These are used 99% of the time. There are other possibilities as well, see https://docs.python.org/2/library/socket.html#socket.SOCK_STREAM (you will have to google for the meaning of each one).

like image 61
freakish Avatar answered Sep 17 '22 18:09

freakish


SOCK_STREAM is a constant indicating the type of socket (TCP), as opposed to SOCK_DGRAM (UDP).

like image 32
shafeen Avatar answered Sep 19 '22 18:09

shafeen