Python Final - Networking

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

In the client-server model, the client sends out a

request to a server.

In the client-server model, the client sends out a request to a server. The server processes the request and sends a

response back to the client

client-server model classic example is a web browser sending a request for a webpage to a webserver. The webserver processes the request and

returns the webpage to the browser

s.bind(addr) binds the

socket object to an address addr

s.accept() passively waits until a connection is made. The return value is a pair (conn, address) where conn is a new ,

socket object usable to send and receive data on the connection

To create a server, we can also use

socket objects

s.accept() passively waits until a connection is made. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the

socket on the other end of the connection

s.connect(addr) creates a connection between the

socket s and the specified address addr

creates a socket object

socket.socket([family, [type]])

Sending and receiving data is often done in

stages

clients, close after a

transaction

s.connect(addr) creates a connection between the socket s and the specified address addr. The addr argument is a

tuple containing the host name (as a string) and port number (as an int)

The type argument is the

type of socket

s.send(string) sends a string to the address to which the socket is currently connected. The return value is the number of bytes sent. There is no guarantee that the

whole message was sent

servers functions (6)

-bind() -listen() -loop: accept(), send() and recv(), close()

clients functions (4)

-connect() -send() -recv() -close()

Python has a socket module which provides access to the

BSD socket interface

In this class, we will only deal with

TCP/IPv4 sockets

The family argument is the

address family

s.send(string) sends a string to the

address to which the socket is currently connected

s.listen(backlog) tells the socket to

begin listening for connections

s.recv(bufsize) receives and returns up to

bufsize bytes of data from the address to which the socket is currently connected

Sending and receiving data is often done in stages - these functions are bound to the

capacity of the network buffers

s.close()

closes the connection.

s.accept() passively waits until a

connection is made.

servers, Listen for

connections

SocketServer library which is made to simplify the task of

creating servers

In this class, we will only deal with TCP/IPv4 sockets. These are the

default arguments

A socket provides an abstraction for the

details of communication

An application can interface with a socket object, which hides the

details of the lower level network protocols

socket.socket([family, [type]]) creates a socket object. Remember, this is one

endpoint of a two-way communication link

A socket is simply an

endpoint of communication.

To create a server, we can also use socket objects. We will just treat them as if they're the other

endpoint of the connection

s.close() closes the connection. Sockets are also automatically closed when

garbage collected

socket.gethostname() returns a string containing the

local machine's primary public hostname

clients, connect when they

need

servers, Listen for connections and communicate with each client using a

new, unique socket object

s.send(string) sends a string to the address to which the socket is currently connected. The return value is the

number of bytes sent

s.accept() passively waits until a connection is made. The return value is a

pair (conn, address)

The coordination of the communication process is defined by the

protocol being used

s.listen(backlog) tells the socket to begin listening for connections. The backlog argument specifies how many connections to

queue before connections become refused (default is zero)

client-server model classic example is a web browser sending a

request for a webpage to a webserver


Kaugnay na mga set ng pag-aaral

BIOLOGY: Lecture Semester Exam Questions

View Set

Lifespan Development Exam 2 Cumulative Set

View Set

Глаголы с группой (цифра) + джище форма

View Set

NUR 420- Practice Questions for Exam 4

View Set

ECO 151 SURVEY OF ECONOMICS - MINE MODULE 1 Economics and the U.S. Economy CH. 1 The Challenge of Economics CH 2 The U.S. Economy

View Set

Chapter 10: Stockholders' Equity

View Set