new Socket(InetAddress address, int port) throws IOException
import java.net.InetAddress;
import java.net.Socket;
public class Main {
public static void main(String[] argv) throws Exception {
InetAddress addr = InetAddress.getByName("java.sun.com");
int port = 80;
Socket socket = new Socket(addr, port);
}
}
Home
Java Book
Networking
Java Book
Networking
Socket:
- Socket
- new Socket(InetAddress address, int port) throws IOException
- Socket: connect(SocketAddress endpoint, int timeout) throws IOException
- Socket: getInputStream() throws IOException
- Socket: getLocalSocketAddress()
- Socket: getOutputStream() throws IOException
- Socket: getRemoteSocketAddress()
- Socket: readUTF() and writeUTF(String str)