— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet442/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   438   439   440   441   442   443   444   445   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

socket 
connections
482
 
chapter 15
Sharpen your pencil
Test your memory of the streams/classes for reading and writing from a 
Socket. Try not to look at the opposite page!
Client
Server
To read text from a Socket:
source
write/draw in the chain of streams the client 
uses to read from the server
Client
Server
To send text to a Socket:
destination
write/draw in the chain of streams the client 
uses to send something to the server
Sharpen your pencil
What two pieces of information does the client need in order to make a 
Socket connection with a server?
Fill in the blanks:
Which TCP port numbers are reserved for ‘well-known services’ like HTTP and FTP?
TRUE or FALSE: The range of valid TCP port numbers can be represented 
by a short primitive?


networking 
and
threads
you are here
4
483
Writing a simple server
So what’s it take to write a server application? Just a 
couple of Sockets. Yes, a couple as in two. A ServerSocket, 
which waits for client requests (when a client makes a 
new Socket()) and a plain old Socket socket to use for 
communication with the client.
ServerSocket
1
Server application makes a ServerSocket, on a specific port 
How it Works:
ServerSocket serverSock = new ServerSocket(4242);
4242
ServerSocket
2
Client makes a Socket connection to the server application
Socket sock = new Socket(“190.165.1.103”, 4242);
4242
Socket
ServerSocket (waiting 
for the next client)
3
Server makes a new Socket to communicate with this client

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   438   439   440   441   442   443   444   445   ...   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