— Scott McNealy, Sun Microsystems Chairman, President and ceo


Client connects to the server by  establishing a Socket



Download 40,57 Mb.
Pdf ko'rish
bet435/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   431   432   433   434   435   436   437   438   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

1
Client connects to the server by 
establishing a Socket connection.
Client A
chat server at 
196.164.1.103, 
port 5000
Make a socket connection to 
196.164.1.103 at port 5000
Server
Send
2
Client sends a message to the server 
Client A
Server 
machine at 
196.164.1.103
writer.println(aMessage)
Server
Receive
3
Client gets a message from the server 
Client A
Server 
machine at 
196.164.1.103
String s = reader.readLine()
Server


networking 
and
threads
you are here
4
475
Make a net work Socket connection
To connect to another machine, we need a Socket connection. 
A Socket ( java.net.Socket class) is an object that represents 
a network connection between two machines. What’s a 
connection? A relationship between two machines, where two 
pieces of software know about each other. Most importantly, 
those two pieces of software know how to communicate with 
each other. In other words, how to send bits to each other. 
We don’t care about the low-level details, thankfully, because 
they’re handled at a much lower place in the ‘networking 
stack’. If you don’t know what the ‘networking stack’ is, don’t 
worry about it. It’s just a way of looking at the layers that 
information (bits) must travel through to get from a Java 
program running in a JVM on some OS, to physical hardware 
(ethernet cables, for example), and back again on some other 
machine. Somebody has to take care of all the dirty details. 
But not you. That somebody is a combination of OS-specific 
software and the Java networking API. The part that you have 
to worry about is high-level—make that very high-level—and 
shockingly simple. Ready?

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   431   432   433   434   435   436   437   438   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish