python socket programming

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

connect_ex(address)

return an error indicator instead of raising exception

send(bytes)

send data to the remote socket; return number of bytes sent.

sockets are used to

send messages across a network

Internet socket

sometimes called BSD (Berkeley Software Distribution) socket

socket() args

specify address family & socket type

AF_INET means

IPv4 protocol

IPC

Inter-process Communication

host can be a

hostname, IP address, or empty string

the loopback interface is also known as

localhost

for deterministic behavior from host

use a numeric addr

port should be an int from

1-65535

IPv4 addr for localhost

127.0.0.1

non-privileged ports are

> 1023

accept()

Blocks and waits for an incoming connection. When client connects, returns a new socket object representing the connection and a tuple holding the address of the client.

if you pass "" as host to server socket, server will

accept connections on all available IPv4 interfaces

bind()

associate socket w/a specific network interface & port number

socket()

create a socket object

NetBIOS

Network Basic Input/Output System

context manager

an object that defines the runtime context to be established when executing a 'with' statement.

socket timeout can be caused by

any connectivity problem on the network

Unix domain sockets can only be used to communicate

between processes on the same host

connect()

called by client to establish connection to the server & initiate 3-way handshake

most common type of socket applications

client-server

"in-order data delivery" means

data is read by application in the order it was written by the sender

listen()

enables a server to accept() connections

network connectivity problem examples

network partition prevents 2 machiens from communicating

"best-effort delivery system"

no guarantee data will reach its destination, or you will receive what's been sent

TCP eliminates worrying about

packet loss, data arriving out-of-order

if passing a hostname to bind

program may show non-deterministic behavior, depending on results from DNS resolution

gaierror

raised for address-related errors by getaddressinfo() and getnameinfo().

recv(bufsize)

receive data from socket; returns bytes object representing data recieved.

close()

releases resource associated w/a connection (call shutdown() before this to close connection in a timely fashion)

TCP (Transmission Control Protocol) benefits

reliability; in-order data delivery

the "with" statement

replaces "try-finally"


Set pelajaran terkait

Chapter 8: Establishing a Constructive Climate

View Set

Chapter 41 Management of pt. with musculoskeletal disorders Prep-U

View Set

Español 1 - Situations - Preguntas Esenciales para la Clase

View Set

Chapter 4: The Structure of the Atom

View Set

Chapter 22 - Integumentary System

View Set