
echo 7/tcp
echo 7/udp
discard 9/tcp
discard 9/udp
systat 11/tcp
daytime 13/tcp
netstat 15/tcp
chargen 19/tcp
ftp 21/tcp
telnet 23/tcp
smtp 25/tcp
time 37/tcp
time 37/udp
name 42/tcp
whois 43/tcp
dns 53/udp
dns 53/tcp
finger 79/tcp
http 80/tcp
pop 110/tcp
auth 113/tcp
nntp 119/tcp
imap 143/tcp
exec 512/tcp
login 513/tcp
who 513/udp
shell 514/tcp
syslog 514/udp
talk 517/udp
route 520/udp
timed 525/udp
...
InetAddress adresse = InetAdress.getLocalHost ();
System.out.println(adresse);
public Socket (String machine, int port) throws UnknownHostException,
IOException
public Socket (InetAddress adresse, int port) throws UnknownHostException,
IOException
public Socket(String machine, int port,
InetAddress local, int portLocal) throws IOException
public Socket(InetAddress adresse, int port,
InetAddress local, int portLocal) throws IOException
public InputStream getInputStream () throws IOException
public OutputStream getOutputStream () throws IOException
public synchronized void setSoTimeout(int timeout) throws SocketException
public synchronized void close () throws IOException
public void setSoLinger(boolean on, int val) throws SocketException
public void setTcpNoDelay(boolean on) throws SocketException
public InetAddress getInetAddress ()
public int getPort ()
public InetAddress getLocalAddress ()
public int getLocalPort ()
int getLocalPort ()
public int getSoLinger() throws SocketException
public synchronized int getSoTimeout() throws SocketException
public boolean getTcpNoDelay() throws SocketException import java.io.*;
import java.net.*;
public class SmtpClient
{
public static void main(String argv[]) throws Exception
{
sendmail("aaa"," odepertat@gfi-info.fr ");
}
static void sendmail(String message, String to)
throws Exception
{
Socket s = new
Socket(InetAddress.getByName("gfi-info.fr"),25);
PrintStream output = new PrintStream(s.getOutputStream());
output.println("HELO de3i \r");
output.println("MAIL FROM: <odepertat@gfi-info.fr\r");
output.println("RCPT TO:<" + to + ">\r");
output.println("DATA\r");
output.println(message);
output.println("\r\n.\r");
}
}
public ServerSocket(int port) throws IOException
public ServerSocket(int port, int count) throws IOException
public ServerSocket(int port,int count, InetAddress locale) throws
IOException
public Socket accept() throws IOException
public synchronized void setSoTimeout(int timeout) throws SocketException
public void close() throws IOException
public int getLocalPort()
public InetAddress getInetAddress()
public synchronized int getSoTimeout() throws IOException import java.net.*;
import java.io.*;
public class SimpleServer
{
boolean runSw=true;
public SimpleServer ()
{
try
{
ServerSocket srv = new ServerSocket(6420);
int num = 0;
String responseBuffer;
System.out.println("Server started !");
do
{
Socket client = srv.accept( ); //waiting for an incoming client
DataInputStream instream =
new DataInputStream(client.getInputStream());
DataOutputStream outstream =
new DataOutputStream(client.getOutputStream());
num++;
responseBuffer = instream.readLine();
if (responseBuffer.startsWith("stop"))
runSw = false;
System.out.println("A client sent : " + responseBuffer);
outstream.writeBytes("You were client number : " + num);
client.close();
} while(runSw);
}
catch (IOException e) { System.out.println(e.getMessage()); }
}
public static void main(String arg[]) { new SimpleServer(); }
}
import java.net.*;
import java.io.*;
public class JavaClient
{
public JavaClient(String message)
{
try
{
System.out.println("About to acquire Host");
InetAddress ipaddr = InetAddress.getLocalHost();
System.out.println("HostAddress="+ipaddr.toString());
Socket srv = new Socket(ipaddr, 6420);
System.out.println("Return from building Socket");
DataOutputStream outstream = new
DataOutputStream(srv.getOutputStream()); //voie out
DataInputStream instream = new DataInputStream(srv.getInputStream());
//voie in
outstream.writeBytes(message + "\n");
System.out.println("Recieved from server : " + instrea m.readLine());
srv.close();
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
}
public static void main(String args[])
{
if (args.length > 0)
{
new JavaClient(args[0]);
}
else
{
System.out.println("Usage : java JavaClient <msg>");
System.out.println("\n");
System.out.println(" java JavaClient stop : stops the server");
}
}
} |
© 2001 IsepFAQtory Tous droits réservés
|