Networking
Protocol
- Data formats
e.g. language - Address formats
e.g. location - Routing
- Acknowledgements and Errors
IP addresses and ports
- IPV4: 32 bits, 4 groups of 8 bits(0~256), 2^32 combinations
- IPV6: 128 bits, 16 groups of 8 bits, 2^128 combinations
- Port range: 0-65535 (first 1023 reserved)
e.g. IPV4- 192.168.0.4:3000
IPV6- [2001:0db8:85a3:0000:0000:8a2e:0370:7334]:3000
LAN and WAN
make connection
LAN: office, wifi
-> internal (private IP address) ->
WAN: extended envir
Data serialization and transport
breakdown the data into chunks, called packets
protocol controls which packet to deliver
URL
scheme://host[:prt]/path[?query#fragment] => key-value pairs
e.g. https://(ip)218.24.0.93:443 or (address)mydomain.com/recipes?unit=metric&ingredients=bananas
DNS
- Domain Name System
- receives queries, give corresponding address
HTTP(s)
Hyper-Tags Transfer Protocol
- HTTPs -> safer
- Request / Response
- server can’t initiate request, only client can initiate
- Stateless
- protocol(http) doesn’t remember any information, server and client do
REST API & Methods
Representational State Transfer
http://server/entities(messages, topics, hosts, …)
- indicated (pre-defined) methods to know what to do with entities
- attached to the header of packets
- GET
- only the safe method, not changing anything
- POST
- PUT
- DELETE
- more…
important to receive good response to smoothly communicate —>
Status Codes
1xx: Hold on
2xx: Here you go
e.g. 201: created(posted) successfully
3xx: Go away
4xx: You fucked up (syntax / fulfilled)
e.g. 404: not found
5xx: I fucked up
en.wikipedia.org/wiki/List_of_HTTP_status_codes
List of HTTP status codes - Wikipedia
From Wikipedia, the free encyclopedia Jump to navigation Jump to search Response codes of the Hypertext Transfer Protocol This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a clien
en.wikipedia.org
Ajax
setting the origin (server) of the client
request: carrying around the data to send and receive
cb: callback -> assign function, passing the function to the API and api returns the data
e.g. cb = fcName
- shouldn’t access the WAPI as it would be from a different origin
but ok if we do it using a script —>- security check if it’s done indirectly
JSONP
update the scripts (.js)
callback the function and run the code: callback -> displayWeather func -> put data as an arg
CORS
Client Origin Resource Sharing
each server can decide whether to accept the JSON callback from client or not
give right (bypass the inability) to access third party APIs
- preflight request -> decide allow or not
- main request
WebSockets
WebRTC
Real Time Communication
WebRTC 는 웹 브라우저 간에 플러그인의 도움 없이 서로 통신할 수 있도록 설계된 API이다.
e.g. chatroulette
: Chatroulette is an online chatwebsite that pairs random users for webcam-based conversations. Visitors to the website begin an online chat (text, audio, and video) with another visitor. At any point, either user may leave the current chat by initiating another random connection.