Chapter_4_NetworkBasic
Chapter_4_NetworkBasic
Chhatrapati SambhajiNagar
Department Of Computer Engineering
2. Use URLConnection class to read and write data to the specified resource
referred by the given URL.
- A socket is bound to a port Number so that the TCP layer can identify the
application that data is destined to be sent to.
2. To create an InetAddress object, we have to use one of the available factory methods.
3. Factory methods are merely a convention whereby static methods in a class return an
instance of that class.
2. byte[ ] getAddress( )
3. String getHostAddress( )
4. String getHostName( )
5. boolean isMulticastAddress( )
Syntax:
}
}
Protocol: https
Host: www.example.com
Port: -1
Default Port: 443
File:
Path:
Query: null
1. This class represents a communication link between the URL and the application.
2. URLConnection is an abstract class that represents an active connection to a resource
specified by a URL
2. can be used to read and write data to the specified resource referred by the URL.
1. The openConnection() method of URL class returns the object of URLConnection class
2. Syntax:
a. java.net.Socket
b. java.net.ServerSocket
Methods :
1. InetAddress getInetAddress( )
2. int getPort( )
3. int getLocalPort( )
4. InputStream getInputStream( )
5. OutputStream getOutputStream( )
Methods