You are on page 1of 6

Chanter 4

O Sesvety Scht () with Values


Constu chor has A lort Value.

TCrlEP mseives lowr 0 ots


Java net
Socket i+15 the Cammuncat end noint.

TCR15 Cohnec tien oviented and ullable.


DP.15 Con nec hon oncurzenl
less

hn: www. ky2. com 8o. is the noy t nunhtr


Pratocol Pat No.
FTP
55H 202
22
TELNET
2
GmTP
pNs (Domàyn Nathe 25
97Sun)
TFTP CTivial fle
Tms) 69
19
hTtP
Pop tPrat 6t) Ilo To
NTP Netwok ews
9
SNnP C
5irinle Metwer 16
Seon Sockel yes
a
HTTP
Znct Address
(lahs Nane
factony methodg LGalled usin
Stetio het hd dre Jet Local Ho9t () haos Uhknrwn Hot Exten fon
hest-na
5Haiu ToetAdress 94by Name (Hing
tIbyName (ing host name)
9t 8y Address (String D addess)

These e Mods- etvin the tanet lurses. by bs)n 9

a dddesges
Jhsdante edhods. L Calecd using object
boolean equals dject andther -j) fad4re5 5

bevs byte 77ay hat 15 ese

byheobj of he Caliny hih.


hin 9eltiHost Add yess Teturs a Stingwr hosid ad dres
of dhe nyaltn okject
n getHas+Mae efuong 4 sting thyt egets the
aeofnehost a the LnetMMzrs
bject.
boolean15lHcagt PAeldress () Teturns twe 1 the nveking
Tntevnet hdBross is mu IH castqd
Shdng o tAng( ) Tetunng the encapsulated stig Co nfain
thebost Dame y P Addr ess.
TCP
Ti6 is ConnecHon oHentec
Cotans 2 cla6ses Sodket Se Sockeb
Sotker 1s Ued both by Hhe Sewer and clents
Constu do0rs af Socket are fo lows
DSoket tor
dcfining dert ekjcck
)Socket l InetAddress addrus9 int not)
not)
.

) Socket TetAddess address nt nort, Inethddros ocal hdd


it loc pert)
Socket CProxy oY) 5) 5sdket C5sdet Sryl impl
) Sscke (n hos, n nost) ) sakrt (ia hog- Ih o
AP
AP L Inethddrevs loal Addr loqlPort)
HPLL
Servn Satket This class ib vsed by Serve glikathong - to gbtaina
pot and listen t for thent eqvest

Constout to5
D5erve Socket c
)Sexver Sacket (int lont
2)

Sver Socke int2 pavt backleg


bt back log ))
MSever cket otint backlagneiAlTess bind Aadr)

JH 6hen ba
5iled kls d ddress

pe

URL CJ455
itis a nonteto a 'soUTLe
URL 1 Unyfoom Resovce ocator
be a ile or ditetoy.
oy Wos ld Wide Web A resouta Can

COnstoucto S
Ubes the stin to Cyeate an oject
URL Stoig hece)
2 URL C Striny otool 5tiny hest, int port5rio file)
Creaes an DRL object voi nrohbco, hst, fnt, file.
URL Csting mototolStig hegh, int noat Sti file Utream
Handley handler
URL (Stalng p»tocel Sing hast Stainy Rle)
http:/ qooCom 8s/4r
5 URL CuRL Lanted 5tin spe) hT
6
O CURL Contest Hing se RLHeanandler ardler )
heheds
Returns the mototo Used fo oh
Stro getPaoocol()
it getfont()
what n t no s Ued
for Lomm
Comunicas
riny geMos+ ( - Ainds ovt he host ot he
Staing getRle t) Finds out the ile U9edte
disale GJebs
St7in9 to Ex ternal fom!)
1 veb pay
Grives the fortmal URL of
he
the
URL
webs
Connechon
To auebs the
actval bits 0
informationht
in UR2 the 15'15
yby 05e URL Connection class. LOnta ned
Method
I
get ontent Lenh Re tu ns
the sie of the
r lared to (ontents
Sring get Confent lype() 7esoU7Ce
-

Retvn she
tne d
Coniend
ong
resouL
9et Date (
Me thod etons
of he dste
date Hine
esn onse Hne
ong get Last Modi fitd
Retuns the d qhe
45t y i me
modification of esyo n(t
Ong get ExpjnaHon
hs
method ehus
of ime
Hime dte
drt
irati on of a zsoU7
3r9o0Ye
Lonst tre ars
oet hput Stream
hs mehod etuans
etuans th
input 5tream q55o ahed
wih he
res ourte
ExExt Methods of RL Class
URL Connec Hon openConnud on ()- onens (onnec Flon
URLConneuhn open (onn eckion hoy ay)
Zn Syntax
URL U new UARL (rww. qmail Com
URLCOWnetHon on
UopenConnechdh

UDP C User Datagdam holotol ConnecHon Less Psho


UR2
thaows Mal hor med URLEx (epH on
where a5 hrous Unknown hos T TOT excenh oh
- DatagTam Packet

Dgtagrom Pachet class i Tsnonsible (onnechion kss


Tnet rddr6s
datag rum delive
get ae-Bddress, SorkthuStket
-
9tt
Congt ddress
.Datagrar Patktt (byte Co bf, it len ) rcves e patkds in thg
2 Datagram Patket (byte r3 buf, int len, Q034y
Tnet Address addrss,
int Lspeded ad
Dqtunam Packet ( byBe [1 but int ottset et
int
,
len ) TCan ine oe
Detagra Padket (byte y but
ioffset, ntln Znet Bddre5
addres, it nont ) Can yive
Ad4, poe, oft
Dsyra) Packet (byte i buf offs et, i9T len seckejt4
alàress LSodhet naAH)s
C
C. Datag2a) Patket C byhh C] but, t len 5ocket nd4 rss
dkress
B4IP
*Detegran 5ocket hetBAbme s
gethddr%, hetAeldres
The Datagram Socket 9e
rer(scsts a
ConnecHon- less
cket tor Local
Sendl ng y seceivin ddhgram natkety *helns m Sending nackefs.a
Con ytrutton $:
Detagan Sochet l - Canbe Comeubd do any availablt t
2
rofecte Day1an fedkt Patag1m ae ket Inpl inn hecand sts
decthed Deiun Suuet (in speched imn)
v+) Connects +s a speciked noyt no
motecred Datagnan 56ehet C int
5 hovt,
ThctAdr ess iddr)- Connecds
matethed Datyran Sotke to a
Speöh
6acket Address ina
ina addr)
addr)
pe no.
nd he

addre
1 s connecdeel do
a
Mheds f sneified Soke dorres
Dakagum Packel
objec.
i gerlot
9 Daka
eLengh )

You might also like