![]() |
subject > component > module > Java module > Java class > ServerSocket class |
![]() ![]() | ||||
ServerSocket class | ||||
subject | fact |
ServerSocket class | has example of accepting a connection the server must have a thread constantly listening for connections using a statement like the following, embedded in a loop: Socket clientSocket = serverSocket.accept(); The above statement will wait indefinitely in the accept method until a client tries to connect, then it will try to create an instance of Socket class to handle the new connection. If this is successful both client and server now have instances of Socket class and can communicate freely with each other. | ![]() |
has example of connecting Socket clientSocket= new Socket(host, port); | ![]() | |
has example of listening ServerSocket serverSocket = new ServerSocket(port); where port is the integer representing the port number on which the server should be listening | ![]() | |
has purpose to allow a server to listen to a port | ![]() | |
is a subtopic of 3.5 - Technology Needed to Build Client-Server Systems | ![]() | |
is an instance of Java class | ![]() | |
see also server socket | ![]() | |
Java class | can extend only one superclass | ![]() |
can have more than one constructor each of which has different sets of arguments | ![]() | |
can have the same name as another class if the two classes are not in the same package and their packages are never imported into the same file | ![]() | |
can implement more than one interface | ![]() | |
has form class classname | ![]() | |
is abstract if it has one or more abstract methods | ![]() | |
is stored in a file of the same name | ![]() | |
may implement particular low-level subsystems | ![]() | |
should be placed in its own source file | ![]() | |
should have a unique name since somebody in the future might want to import the packages containing both classes and hence create a name clash | ![]() | |
should order elements as follows: | ![]() | |
uses an implements clause to declare that it contains methods for each of the operations specified by the interface | ![]() | |
class | contains all of the code that relates to its objects including | ![]() |
contains data associated with each object | ![]() | |
declares a list of variables, called instance variables, corresponding to data that will be present in each instance | ![]() | |
has part class name | ![]() | |
has part class variable | ![]() | |
has part code | ![]() | |
has part constructor | ![]() | |
has part instance variable | ![]() | |
has part method | ![]() | |
has part variables | ![]() | |
is divided up into methods | ![]() | |
is drawn as a box with the name of the class inside in a UML class diagram | ![]() | |
is needed in a domain model if you have to store or manipulate instances of it in order to implement a requirement | ![]() | |
represents several similar objects | ![]() | |
should be created to hold a responsibility if the responsibility cannot be attributed to any of the existing classes | ![]() | |
should be named after things their instances represent in the real world | ![]() | |
should not be named after the internals of a computer system such as 'Record', 'Table', 'Data', 'Structure', or 'Information' | ![]() | |
data abstraction | groups the pieces of data that describe some entity, so that programmers can manipulate that data as a unit | ![]() |
helps a programmer to cope with the complexity of data | ![]() | |
hides the details of data | ![]() | |
module | has high cohesion if related aspects of a system are kept together in this module, and unrelated aspects are kept out | ![]() |
lacks side effects if it does not modify any data, and does not leave behind any information, other than its result, that would have an effect on other computations | ![]() | |
component | may perform a special-purpose function such as the user interface for a particular system | ![]() |
Next Java class: Socket class Up: Java class Previous Java class: Locale class