Public Socket (InetAddress host, int port, InetAddress localAddress, int localPort) throws IOException.Ĭreates a socket and connects it to the specified remote port on the specified remote address.Ĭreate an unconnected socket, the system default type SocketImpl Public Socket (String host, int port, InetAddress localAddress, int localPort) throws IOException.Ĭreates a socket and connects it to the specified remote port on the specified remote host. Public Socket (InetAddress host, int port ) throws IOExceptionĬreates a stream socket and connects it to the specified IP address of the specified port number. Public Socket (String host, int port ) throws UnknownHostException, IOException.Ĭreates a stream socket and connects it to the specified port number on the specified host. To obtain a client Socket object by instantiating and the server to get a Socket object is returned by value accept () method. class behalf of the client and server to communicate with each other in the socket. Public void bind (SocketAddress host, int backlog)īinds the ServerSocket to a specific address (IP address and port number). Public Socket accept () throws IOExceptionīy specifying the timeout value to enable / disable SO_TIMEOUT, in milliseconds. Returns the port on which this socket is listening. Here are some common methods ServerSocket class: No. If the ServerSocket constructor method does not throw an exception, it means that your application has been successfully bound to the specified port, and listens for client requests. Public ServerSocket () throws IOExceptionĬreates an unbound server socket. Using the specified port, listen backlog, and to bind to the local IP address of the server is created. Public ServerSocket (int port, int backlog, InetAddress address) throws IOException With the specified backlog Creates a server socket and binds it to the specified local port number. Public ServerSocket (int port, int backlog ) throws IOException Public ServerSocket (int port) throws IOExceptionĬreate a binding to a specific port of the server socket. ServerSocket class has four constructors: No. Server applications by using class for a port and listens for client requests. The following is a complete class provides several useful methods to achieve sockets. TCP is a bidirectional communication protocol, so data can be sent through the two data streams at the same time. Client input stream output stream to a server, the client's input stream to the server output stream. Each socket has an input and an output stream stream.
URL Processing: This chapter talked in another space, click here to learn more about the URL handling Java language.Socket Programming: This is the most widely used network concept, it has been explained in great detail to.This tutorial explains the following two topics. Providing the data packet to be transmitted between the application data. UDP: UDP is an abbreviation of User Datagram Protocol, a connectionless protocol.
Commonly used for Internet protocol, called TCP / IP. TCP: TCP is the abbreviation for Transmission Control Protocol, which guarantees reliable communication between two applications.package provides support for two common network protocols: You can use these classes and interfaces to focus on solving the problem, rather than focus on communication details. package in the J2SE API contains classes and interfaces that provide low-level communication details. Network programming means to write run on multiple devices (computer) program, these devices are connected through a network.