Git Product home page Git Product logo

cmput404lab2's Introduction

Answers to Lab2 Questions

  1. How do you specify a TCP socket in Python?

by calling socket.socket, we initiate a socket. by giving it a SOCK_STREAM option, we specify that the socket is a TCP socket.

  1. What is the difference between a client socket and a server socket in Python?

Different socket options: server socket needs the port reuse option to keep listening on the same port. The client socket doesn't care about which port to use.

Different behaviour: server socket needs to bind to a port and host and start listening, while a client socket only needs to connect.

  1. How do we instruct the OS to let us reuse the same bind port?

by calling s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

  1. What information do we get about incoming connections?

the address of incoming connection, and the socket

  1. What is returned by recv() from the server after it is done sending the HTTP request?

None

  1. https://github.com/c25vdw/cmput404lab2

Usage

  • python3 proxy_client.py to start a multi-thread/process client
  • python3 proxy_server.py to start a forking server

proxy_client and proxy_server provides option to set the proxy host and port, using --host <hostname> --port <port>. Short hand is supported, too. For example, python3 proxy_client.py -H 127.0.0.1 -p 8001 tells the client to assume proxy server running at 127.0.0.1:8001

cmput404lab2's People

Contributors

c25vdw avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.