Chapter 21: Connecting with a Network

Similar documents
Anouncements. Conjugate Gradients. Steepest Descent. Outline. Steepest Descent. Steepest Descent

Quality Monitoring Calibration Assuring Standardization Among Monitors

1973 AP Calculus BC: Section I

k of the incident wave) will be greater t is too small to satisfy the required kinematics boundary condition, (19)

The Exile Began. Family Journal Page. God Called Jeremiah Jeremiah 1. Preschool. below. Tell. them too. Kids. Ke Passage: Ezekiel 37:27

NEWBERRY FOREST MGT UNIT Stand Level Information Compartment: 10 Entry Year: 2001

GUIDE FOR SUPERVISORS 1. This event runs most efficiently with two to four extra volunteers to help proctor students and grade the student

Continous system: differential equations

( A) ( B) ( C) ( D) ( E)

P a g e 5 1 of R e p o r t P B 4 / 0 9

T h e C S E T I P r o j e c t

An Asymptotic Expansion for the Non-Central Chi-square Distribution. By Jinan Hamzah Farhood Department of Mathematics College of Education

CENG 3420 Computer Organization and Design. Lecture 07: Pipeline Review. Bei Yu

Wireless Networking Guide

Fourier Series: main points

Phys Nov. 3, 2017 Today s Topics. Continue Chapter 2: Electromagnetic Theory, Photons, and Light Reading for Next Time

Phase plane method is an important graphical methods to deal with problems related to a second-order autonomous system.

Mixing time with Coupling

Boyce/DiPrima/Meade 11 th ed, Ch 4.1: Higher Order Linear ODEs: General Theory

(Reference: sections in Silberberg 5 th ed.)

Existence of Nonoscillatory Solutions for a Class of N-order Neutral Differential Systems

Assessing Student Work MATH RUBRIC. Understanding Reasoning Accuracy Communication

Nocturnes Nocturne op. 27 Nº.2 in D b Major

1. Mathematical tools which make your life much simpler 1.1. Useful approximation formula using a natural logarithm

SHINGLETON FOREST AREA Stand Level Information Compartment: 44 Entry Year: 2009

ALU. Announcements. Lecture 9. Pipeline Hazards. Review: Single-cycle Datapath (load instruction) Review: Multi-cycle Datapath. R e g s.

Department of Mathematics. Birla Institute of Technology, Mesra, Ranchi MA 2201(Advanced Engg. Mathematics) Session: Tutorial Sheet No.

Convergence tests for the cluster DFT calculations

1 Notes on Little s Law (l = λw)

A L A BA M A L A W R E V IE W

RAKE Receiver with Adaptive Interference Cancellers for a DS-CDMA System in Multipath Fading Channels

Valley Forge Middle School Fencing Project Facilities Committee Meeting February 2016

Response of LTI Systems to Complex Exponentials

Big O Notation for Time Complexity of Algorithms

Part B: Transform Methods. Professor E. Ambikairajah UNSW, Australia

OH BOY! Story. N a r r a t iv e a n d o bj e c t s th ea t e r Fo r a l l a g e s, fr o m th e a ge of 9

Study of Tyre Damping Ratio and In-Plane Time Domain Simulation with Modal Parameter Tyre Model (MPTM)

Lecture 2: Bayesian inference - Discrete probability models

Data Structures Lecture 3

Web-appendix 1: macro to calculate the range of ( ρ, for which R is positive definite

Math 2414 Homework Set 7 Solutions 10 Points

Numerical Simulation for the 2-D Heat Equation with Derivative Boundary Conditions

Partial Fraction Expansion

CS 326e F2002 Lab 1. Basic Network Setup & Ethereal Time: 2 hrs

MAT3700. Tutorial Letter 201/2/2016. Mathematics III (Engineering) Semester 2. Department of Mathematical sciences MAT3700/201/2/2016

Representing Knowledge. CS 188: Artificial Intelligence Fall Properties of BNs. Independence? Reachability (the Bayes Ball) Example

Chapter. (Courtesy auremar/shutterstock) Advanced Formatting and Workbook Features

Note 6 Frequency Response

Boyce/DiPrima 9 th ed, Ch 7.6: Complex Eigenvalues

CS 61C: Great Ideas in Computer Architecture Control and Pipelining, Part II. Anything can be represented as a number, i.e., data or instrucwons

Homework: Introduction to Motion

EE Control Systems LECTURE 11

Part I- Wave Reflection and Transmission at Normal Incident. Part II- Wave Reflection and Transmission at Oblique Incident

1985 AP Calculus BC: Section I

CS 188: Artificial Intelligence Fall Probabilistic Models

DSP-First, 2/e. This Lecture: LECTURE #3 Complex Exponentials & Complex Numbers. Introduce more tools for manipulating complex numbers

PLS-CADD DRAWING N IC TR EC EL L RA IVE ) R U AT H R ER 0. IDT FO P 9-1 W T OO -1 0 D EN C 0 E M ER C 3 FIN SE W SE DE EA PO /4 O 1 AY D E ) (N W AN N

Get Funky this Christmas Season with the Crew from Chunky Custard

Great Idea #4: Parallelism. CS 61C: Great Ideas in Computer Architecture. Pipelining Hazards. Agenda. Review of Last Lecture

Beechwood Music Department Staff

P a g e 3 6 of R e p o r t P B 4 / 0 9

Nocturnes Nocturne op. 15 Nº.2 in F # Major

The Moúõ. ExplÉüers. Fun Facts. WÉüd Proèô. Parts oì Sp. Zoú Animal Roêks

Physics 111. Lecture 38 (Walker: ) Phase Change Latent Heat. May 6, The Three Basic Phases of Matter. Solid Liquid Gas

2 f(x) dx = 1, 0. 2f(x 1) dx d) 1 4t t6 t. t 2 dt i)

THIS PAGE DECLASSIFIED IAW EO IRIS u blic Record. Key I fo mation. Ma n: AIR MATERIEL COMM ND. Adm ni trative Mar ings.

8. Queueing systems. Contents. Simple teletraffic model. Pure queueing system

F.Y. Diploma : Sem. II [AE/CH/FG/ME/PT/PG] Applied Mathematics

THIS PAGE DECLASSIFIED IAW EO 12958

Analytical Evaluation of Multicenter Nuclear Attraction Integrals for Slater-Type Orbitals Using Guseinov Rotation-Angular Function

Dynamics of Bloch Electrons 1

Silv. Criteria Met? Condition

Lecture 1: Numerical Integration The Trapezoidal and Simpson s Rule

The Non-Truncated Bulk Arrival Queue M x /M/1 with Reneging, Balking, State-Dependent and an Additional Server for Longer Queues

Review Answers for E&CE 700T02

CSE 202: Design and Analysis of Algorithms Lecture 16

The Central Limit Theorems for Sums of Powers of Function of Independent Random Variables

ENGG 1203 Tutorial. Difference Equations. Find the Pole(s) Finding Equations and Poles

Final Exam : Solutions

EDEXCEL NATIONAL CERTIFICATE UNIT 28 FURTHER MATHEMATICS FOR TECHNICIANS OUTCOME 2- ALGEBRAIC TECHNIQUES TUTORIAL 1 - PROGRESSIONS

Creative Office / R&D Space

EEC 483 Computer Organization

Comparing Different Estimators for Parameters of Kumaraswamy Distribution

Bethe-Salpeter Equation Green s Function and the Bethe-Salpeter Equation for Effective Interaction in the Ladder Approximation

Control Systems. Transient and Steady State Response.

14.02 Principles of Macroeconomics Fall 2005

Lecture Y4: Computational Optics I

Structural Hazard #1: Single Memory (1/2)! Structural Hazard #1: Single Memory (2/2)! Review! Pipelining is a BIG idea! Optimal Pipeline! !

F.Y. Diploma : Sem. II [CE/CR/CS] Applied Mathematics

Right Angle Trigonometry

Instrumentation for Characterization of Nanomaterials (v11) 11. Crystal Potential

Poisson Arrival Process

Cylon BACnet Unitary Controller (CBT) Range

1 Lecture: pp

Sampling of Continuous-time Signals

Supplementary Information for Thermal Noises in an Aqueous Quadrupole Micro- and Nano-Trap

Handout on. Crystal Symmetries and Energy Bands

The far field calculation: Approximate and exact solutions. Persa Kyritsi November 10th, 2005 B2-109

ECE-314 Fall 2012 Review Questions

Chapter 3 Linear Equations of Higher Order (Page # 144)

Transcription:

Pag 319 This chap discusss how o us h BASIC-256 wokig sams. Nwokig i BASIC-256 will allow fo a simpl "sock" cocio usig TCP (Tasmissio Cool Poocol). This chap is o ma o b a full ioducio o TCP/IP sock pogammig. Sock Cocio: TCP sam socks ca a cocio bw wo compus o pogams. Packs of ifomaio may b s ad civd i a bidicioal (o wo way) ma ov h cocio. To sa a cocio w d o compu o pogam o ac as a sv (o wai fo h icomig lpho call) ad h oh o b a cli (o mak h lpho call). Illusaio 40 shows gaphically how a sam cocio is mad. 1. Sv 2. 3. Cli 1. Sv liss fo cli o coc 2. Cli cocs o po 3. Bi-dicioal (2-way) commuicaio bw cli ad sv. Illusaio 40: Sock Commuicaio 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

Pag 320 Jus lik wih a lpho call, h pso makig h call (cli) ds o kow h pho umb of h pso hy a callig (sv). W call ha umb a IP addss. BASIC-256 uss IP vsio 4 addsss ha a usually xpssd as fou umbs spaad by piods (A.B.C.D) wh A, B, C, ad D a ig valus fom 0 o 255. I addiio o havig h IP addss fo h sv, h cli ad sv mus also alk o ach-oh ov a po. You ca hik of h po as a lpho xsio i a lag compay. A pso is assigd a xsio (po) o asw (sv) ad if you wa o alk o ha pso you (cli) call ha xsio. Th po umb may b bw 0 ad 65535 bu vaious I ad oh applicaios hav b svd pos i h ag of 0-1023. I is commdd ha you avoid usig hs pos. A Simpl Sv ad Cli: 1 2 3 4 5 6 7 c21_simplsv.kbs sd a mssag o h cli o po 999 pi "lisig o po 9999 o " + addss() NLis 9999 NWi "Th simpl sv s his mssag." NClos Pogam 129: Simpl Nwok Sv 1 2 3 4 5 6 c21_simplcli.kbs coc o simpl sv ad g h mssag ipu "Wha is h addss of h simpl_sv?", add$ if add$ = "" h add$ = "127.0.0.1" 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

7 8 9 Pag 321 NCoc add$, 9999 pi NRad NClos Pogam 130: Simpl Nwok Cli lisig o po 9999 o xx.xx.xx.xx Sampl Oupu 129: Simpl Nwok Sv Wha is h addss of h simpl_sv? Th simpl sv s his mssag. Sampl Oupu 130: Simpl Nwok Cli addss addss ( ) Fucio ha us a sig coaiig h umic IPv4 wok addss fo his machi. lis lis lis lis poumb ( poumb ) sockumb, poumb ( sockumb, poumb ) Op up a wok cocio (sv) o a spcific po addss ad wai fo aoh pogam o coc. If sockumb is o spcifid sock umb zo (0) will b usd. 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

Pag 322 clos clos ( ) clos sockumb clos ( sockumb ) Clos h spcifid wok cocio (sock). If sockumb is o spcifid sock umb zo (0) will b closd. wi wi wi wi sig ( sig ) sockumb, sig ( sockumb, sig ) Sd a sig o h spcifid op wok cocio. If sockumb is o spcifid sock umb zo (0) will b wi o. coc coc coc coc ) svam, poumb ( svam, poumb ) sockumb, svam, poumb ( sockumb, svam, poumb Op a wok cocio (cli) o a sv. Th IP addss o hos am of a sv a spcifid i h svam agum, ad h spcific wok po umb. If sockumb is o spcifid sock umb zo (0) will b usd fo h cocio. 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

Pag 323 ad ad ( ) ad ( sockumb ) Rad daa fom h spcifid wok cocio ad u i as a sig. This fucio is blockig (i will wai uil daa is civd). If sockumb is o spcifid sock umb zo (0) will b ad fom. Nwok Cha: This xampl adds o w fucio (daa) o h wokig sams w hav alady ioducd. Us of his w fucio will allow ou wok clis o pocss oh vs, lik kysoks, ad h ad wok daa oly wh h is daa o b ad. Th wok cha pogam (Eo: Rfc souc o foud) combis h cli ad sv pogam io o. If you sa h applicaio ad i is uabl o coc o a sv h o is appd ad h pogam h bcoms a sv. This is o of may possibl mhods o allow a sigl pogam o fill boh ols. 1 2 3 4 5 6 7 8 9 10 c21_cha.kbs us po 9999 fo simpl cha ipu "Cha o addss (u fo sv o local hos)?", add$ if add$ = "" h add$ = "127.0.0.1" y o coc o sv - if h is o o bcom o y NCoc add$, 9999 cach 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 Pag 324 pi "saig sv - waiig fo cha cli" NLis 9999 d y pi "cocd" whil u g ky pssd ad sd i k = ky if k <> 0 h call show(k) wi sig(k) g ky fom wok ad show i if NDaa() h k = i(nrad()) call show(k) paus.01 d whil d suboui show(kyvalu) if kyvalu=16777220 h pi ls pi ch(kyvalu); d suboui Pogam 131: Nwok Cha Th followig is obsvd wh h us o h cli yps h mssag "HI SERVER" ad h h us o h sv yps "HI CLIENT". Cha o addss (u fo sv o local hos)? saig sv - waiig fo cha cli 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

Pag 325 cocd HI SERVER HI CLIENT Sampl Oupu 131.1: Nwok Cha (Sv) Cha o addss (u fo sv o local hos)? cocd HI SERVER HI CLIENT Sampl Oupu 131.2: Nwok Cha (Cli) daa o daa() daa ( sockumb ) Rus u if h is wok daa waiig o b ad. This allows fo h pogam o coiu opaios wihou waiig fo a wok pack o aiv. Th big pogam his chap cas a wo play wokd ak bal gam. Each play is h whi ak o hi sc ad h oh play is h black ak. Us h aow kys o oa ad mov. Shoo wih h spac ba. 1 c21_bal.kbs 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 Pag 326 uss po 9998 fo sv spidim 4 call akspi(0,whi) m call akspi(1,black) oppo call pojcilspi(2,blu) my sho call pojcilspi(3,d) oppo sho kspac = 32 klf = 16777234 kigh = 16777236 kup = 16777235 kdow = 16777237 d = pi / 20 dxy = 2.5 mov shodxy = 5 po = 9998 pi pi pi pi pi dicio chag spd sho mov spd po o commuica o "Tak Bal - You a h whi ak." "You missio is o shoo ad kill h" "black o. Us aows o mov ad" "spac o shoo." ipu "A you h sv? (y o )", mod$ if mod$ = "y" h pi "You a h sv. Waiig fo a cli o coc." NLis po ls ipu "Sv Addss o coc o (u fo local hos)?", add$ if add$ = "" h add$ = "127.0.0.1" NCoc add$, po s my dfaul posiio ad sd o my oppo x = 100 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 Pag 327 y = 100 = 0 pojcil posiio dicio ad visibl p = fals px = 0 py = 0 p = 0 call wiposiio(x,y,,p,px,py,p) upda h sc colo g c 0, 0, gaphwidh, gaphhigh spishow 0 spishow 1 spiplac 0, x, y, 1, whil u g ky pssd ad mov ak o h sc k = ky if k <> 0 h if k = kup h x = ( gaphwidh + x + si() * dxy ) % gaphwidh y = ( gaphhigh + y - cos() * dxy ) % gaphhigh if k = kdow h x = ( gaphwidh + x - si() * dxy ) % gaphwidh y = ( gaphhigh + y + cos() * dxy ) % gaphhigh if k = klf h = - d if k = kigh h = + d if k = kspac h p = px = x py = y p = u 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 Pag 328 spishow 2 spiplac 0, x, y, 1, call wiposiio( x, y,, p, px, py, p ) if spicollid( 0, 1 ) h wi "F" pi "You jus a io h oh ak ad you boh did. Gam Ov." d mov my pojcil (if h is o) if p h px = px + si( p ) * shodxy py = py - cos( p ) * shodxy spiplac 2, px, py, 1, p if spicollid( 1, 2 ) h NWi "W" pi "You killd you oppo. Gam ov." d if px < 0 o px > gaphwidh o py < 0 o py > gaphhigh h p = fals spihid 2 call wiposiio( x, y,, p, px, py, p ) g posiio fom wok ad s locaio vaiabls fo h oppo flip h coodias as w dcod whil NDaa() posiio$ = NRad() whil posiio$ <> "" if lf(posiio$,1) = "W" h pi "You Did. - Gam Ov" d 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 Pag 329 if lf(posiio$,1) = "F" h pi "You w hi ad you boh did. Gam Ov" d op_x = gaphwidh - upad( f( posiio$ ), 3) op_y = gaphhigh upad( f( posiio$ ), 3) op_ = pi + upad( f( posiio$ ), 5) op_p = upad( f( posiio$ ), 1) op_px = gaphwidh upad( f( posiio$ ), 3) op_py = gaphhigh upad( f( posiio$ ), 3) op_p = pi + upad( f( posiio$ ), 5) display oppo spiplac 1, op_x, op_y, 1, op_ if op_p h spishow 3 spiplac 3, op_px, op_py, 1, op_p ls spihid 3 d whil d whil paus.05 d whil suboui wiposiio(x,y,,p,px,py,p) posiio$ = lpad$( i( x ), 3 ) + lpad$ ( i( y ), 3 ) + lpad$(, 5 ) + lpad$( p, 1 ) + lpad$( i( px ), 3 ) + lpad$( i( py ), 3 ) + lpad$ ( p, 5 ) NWi posiio$ d suboui fucio lpad$(, l ) 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 Pag 330 u a umb lf paddd i spacs s$ = lf(, l ) whil lgh( s$ ) < l s$ = " " + s$ d whil u s$ d fucio fucio upad( f( l$ ), l ) u a umb a h bgiig paddd i l spacs ad sho h sig by l ha w jus pulld off = floa( lf( l$, l ) ) if lgh( l$ ) > l h l$ = mid( l$, l + 1, 99999 ) ls l$ = "" u d fucio suboui akspi( spiumb, c ) colo c spipoly spiumb, {0,0, 7,0, 7,7, 14,7, 20,0, 26,7, 33,7, 33,0, 40,0, 40,40, 33,40, 33,33, 7,33, 7,40, 0,40} d suboui suboui pojcilspi( spiumb, c) colo c spipoly spiumb, {3,0, 3,8, 0,8} d suboui Pogam 132: Nwok Tak Bal 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

Pag 331 Sampl Oupu 43: Addig Machi - Usig Exi Whil Exciss: m j v p k v h d f k x d c i w l p i o l o i c o s c s a v x w i k d v g p g k c o m s o l c c o c cli, lis, clos, coc, lis, ad, wok, wi, po, sv, sock, cp 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)

Pag 332 21.1. Modify Poblm 12.4 o ca a wok cli/sv 2 play pig-pog gam. 21.2. Wi a simpl sv/cli ock-pap-scissos gam wh wo plays will comp. 21.3. Wi a complx wok cha sv ha ca coc o sval clis a oc. You will d a sv pocss o assig ach cli a diff po o h sv fo h acual cha affic. 2014 Jams M. Rau (CC BY-NC-SA 3.0 US)