Java 4TH Chapter - 22517
Java 4TH Chapter - 22517
1 Calling ServerSocket() constructor with port 39 The class which encapsulates both the
value 'zero' means______________________. numerical IP address and the domain name for
that address. InetAddress
use a port number that is automatically allocated.
Edit Delete
41 The constructor which is used to create client
socket is ____________.
2 TCP/IP reserves the ____________ ports for
specific protocols Socket(InetAddress IPAddress, int port)
1024
44 The java.net.InetAddress class provides
methods to get the________________________
9 Access control does not deals with
IP of any host name
Authenication
129 You can obtain the server's hostname by 191 Select proper method used to create the
invoking __________________on an applet. instance InetAddress class.
getCodeBase().getHost()
getLocalHost(),getByName(),getAllByName()
179 InputStream class is used in TCP Client- 224 The server listens for a connection request
server program to from a client using the following statement:
Send/receive message from client to server Socket s = serverSocket.accept()
184 openConnection() method returns 266 What is the use of bind() method
Returns a URLConnection object bind a socket to a local IP address and port
187 returns the socket and establish a connection 267 What is the use of writeUTF( ) method?
between server and client.
This method writes a string into underlying
public Socket accept() output stream
AJP (22517)
CHAPTER 4 ~ NETWORKING BASICS
• Inet Address -> host name or numerical ip address of the corresponding host
- Factory Methods
1) getLocalHost()
2) getByName()
3) getAllByName()
AJP (22517)
CHAPTER 4 ~ NETWORKING BASICS
• Instance addresses
• URL:-
- It throws MalformedURLException
- url Format is -> protocol/hostname/port number/file path
- It uses following constructors:-
1) URL(String URLString);
2) URL(String protocolName, String hos, int port, String path)
3) URL(String protocolName, String host, String path)
- Methods are as follows:
• Server Program:-
- ServerSocket server_socket=new ServerSocket(1234);
- BufferedReader is for creating the object client_input.
1) getInputStream() - This returns an input stream from the other side.
• Client Program:-
- Socket client_socket=new Socket(“aap”,1234);
- The BufferedReader object is created to read the input from keyboard.
- The InputStreamReader is for reading the stream input.
• Datagrams
- A datagram is an independent, self-contained message.
- The java.net package contains following 3 classes to send receive packets:
1) DatagramSocket
2) DatagramPacket
3) MulticastSocket
• Datagram Packet
- An application can send and receive DatagramPackets through a
DatagramSocket.
- Constructors used:
• DatagramPacket(byte[] barr, int length) : It creates a datagram packet. This
constructor is used to receive the packets.
• DatagramPacket(byte[] barr, int length, InetAddress address, int port) : It
creates a datagram packet. This constructor is used to send the packets.
AJP (22517)
CHAPTER 4 ~ NETWORKING BASICS