Socket Programming Learning Notes (1), Unix Sockets and Windows Sockets

Source: Internet
Author: User
Tags socket in domain

1, about UNIX sockets

1.1 What is a socket?

The socket is a network file descriptor. In the socket based programming technology, the user does not directly access the network interface device to send and receive packets, but establishes an intermediate file descriptor to handle the operation of the programming interface to the network.

What does the 1.2 socket include?

A special communication domain, such as a network connection

A particular type of communication, such as a stream or datagram.

A special protocol, such as TCP or UDP.

1.3 UNIX socket () C function Detailed description:

int socket (int domain, int type, int protocol)

Values in domain:

Pf_unix UNIX IPC Communication

Pf_inet IPV4 Communication

Pf_inet6ipv6

Pf_ipx Novell IPX

Pf_netlinkkernel user Interface Driver

Pf_x25 X.25

pf_ax25

PF_ATMPVCATM PVC

Pf_appletalkappletalk protocol

Pf_packet low-Level packet interface

Value of type:

Sock_stream using connection-oriented communication packs

Sock_dgram use of connectionless communication packets

Sock_seqpacket uses a connection-oriented communication packet with a fixed maximum length

Sock_raw using the original IP packet

SOCK_RDM Reliable datagram using an order of no guarantee

Protocol:

Typically, the default protocol corresponding to type is used, expressed in 0.

For example: int newsocket = socket (pf_inet, sock_stream, 0);//Using TCP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.