java.lang.Object
javax.net.SocketFactory
- Direct Known Subclasses:
- SSLSocketFactory
- See Also:
- Top Examples, Source Code,
ServerSocketFactory
public Socket createSocket()
throws IOException
- See Also:
Socket.Socket()
, Socket.connect(java.net.SocketAddress, int)
, Socket.connect(java.net.SocketAddress)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[285]Send data over socket
By Anonymous on 2003/06/26 09:20:47 Rate
//see also ServerSocketFactory
import java.io.*;
import java.net.*;
import javax.net.*;
public class Sender {
private SocketFactory factory;
public Sender ( ) {
setSocketFactory ( SocketFactory.getDefault ( ) ) ;
}
public void setSocketFactory (
SocketFactory factory ) {
this.factory = factory;
}
public void send ( String message, String host,
int port )
throws IOException
{
int bytes;
Socket socket;
OutputStream out;
socket = factory.createSocket ( host, port ) ;
out = socket.getOutputStream ( ) ;
out.write ( message.getBytes ( ) ) ;
socket.close ( ) ;
}
}
public abstract Socket createSocket(String host,
int port)
throws IOException,
UnknownHostException
- See Also:
Socket.Socket(String, int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Socket createSocket(String host,
int port,
InetAddress localHost,
int localPort)
throws IOException,
UnknownHostException
- See Also:
Socket.Socket(String, int, java.net.InetAddress, int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Socket createSocket(InetAddress host,
int port)
throws IOException
- See Also:
Socket.Socket(java.net.InetAddress, int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Socket createSocket(InetAddress address,
int port,
InetAddress localAddress,
int localPort)
throws IOException
- See Also:
Socket.Socket(java.net.InetAddress, int,
java.net.InetAddress, int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static SocketFactory getDefault()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected SocketFactory()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples