📄 touristinfo.java
字号:
// TouristInfo.java
// Andrew Davison, July 2003 (dandrew@ratree.psu.ac.th)
/* Stores information about a single client:
the client's IP address, port, and output stream
The output stream is used to send messages to the client.
The address and port are used to uniquely identify the
client (the client has no name).
Very similar to Chatter in the multithreaded Chat server.
*/
import java.io.*;
public class TouristInfo
{
String cliAddr;
int port;
PrintWriter out;
public TouristInfo(String cliAddr, int port, PrintWriter out)
{ this.cliAddr = cliAddr;
this.port = port; this.out = out;
}
public boolean matches(String ca, int p)
{
if (cliAddr.equals(ca) && (port == p))
return true;
return false;
}
public void sendMessage(String msg)
{ // System.out.println("sendMessage to (" + cliAddr + "," +
// port + ") : " + msg);
out.println(msg);
}
// public String toString()
// { return cliAddr + " & " + port + " & "; }
} // end of TouristInfo class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -