— Scott McNealy, Sun Microsystems Chairman, President and ceo



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

Server_Why_am_I_here_Don’t_expect_ME_to_answer_that._So,_why_am_Client_A_How_it_Works:_Message_received_5'>Server_Client_A_Server,_I’d_like_to_connect_to_the_chat_service_Server_Client_A_OK,_you’re_in._Participants:__1._Client_A'>Server
Client A
Server, I’d like to connect 
to the chat service
Server
Client A
OK, you’re in. 
Participants:
1. Client A
Server
Why am I here?
Don’t expect 
ME to answer 
that. So, why am 
Client B
Participants:
1. Client A
2. Client B
Server
Why am I here?
Don’t expect 
ME to answer 
that. So, why am 
Client A
How it Works:
Message 
received
5
The server distributes the 
message to ALL participants 
(including the original sender)
Server
Why am I here?
Don’t expect 
ME to answer 
that. So, why am 
Client A
Message 
distributed to 
all participants
Why am I here?
Don’t expect 
ME to answer 
that. So, why am 
Client B
Waiting for 
client requests
OK, you’re in. 
Server, I’d like to connect 
to the chat service
“Who took the lava lamp 
from my dorm room?”
“Who took the lava lamp 
from my dorm room?”


socket 
connections
474
 
chapter 15
Connecting, Sending, and Receiving
The three things we have to learn to get the client working are :
1) How to establish the initial connection between the client and server
2) How to send messages to the server
3) How to receive messages from the server
There’s a lot of low-level stuff that has to happen for these things to work. But we’re 
lucky, because the Java API networking package (java.net) makes it a piece of cake 
for programmers. You’ll see a lot more GUI code than networking and I/O code.
And that’s not all.
Lurking within the simple chat client is a problem we haven’t faced so far in this 
book: doing two things at the same time. Establishing a connection is a one-time 
operation (that either works or fails). But after that, a chat participant wants to 
send outgoing messages and simultaneously receive incoming messages from the other 
participants (via the server). Hmmmm... that one’s going to take a little thought, but 
we’ll get there in just a few pages. 
Connect

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   430   431   432   433   434   435   436   437   ...   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