In-class notes for 01/10/2018
CS 284 (MCA), Interim 2018
Eclipse Lab assignment due at "midnight"
Quiz this afternoon 1pm. Topics
Quiz 1 returned before lunch if possible
This session: Lab 6: Networking communication in Java
Submitted questions on assignments and technology
Network communications in Java
Network concepts: host name, TCP ports. (Port assignments per person)
Basics of network communication via sockets:
Socket as an endpoint for communication. Need to connect sockets on different hosts.
The
Socket
andServerSocket
classesSocket connect()
method for attempting to connect via a "server socket" on a particular host and port.ServerSocket accept()
method for receiving connection requests. If anaccept()
call succeeds, it returns a freshSocket
object for the server to communicate to that client that requested connection.
Can then obtain
OutputStream
(s) and/orInputStream
(s) fromSocket
objects to perform I/O operations across the network.Close sockets when finished.
-
Demo of
net/Sender.java
andnet/Receiver.java
-
Exercise: Compile and run these programs in class together with someone else on another Link machine.
Exercise: Find these elements in
net/Sender.java
and
net/Receiver.java
Lab exercises and javadoc
Objects representing individual network communications (Message classes).
Defining constructors in Java (see constructor in
Account.java
)The javadoc documentation system; stub implementations (example: Account.java members other than constructor)
Annotations:
/**, @param, @return, @exception, @author
% javadoc -author -package Account.java
Results:
Account.html
The class
StringTokenizer
for parsing strings. MethodsnextToken()
andcountTokens()
.
Looking ahead
Read Threads page in Java "text" area; submit at least one reading question by tonight "midnight"
React native GUIs - Deandre
< >