Go Back   UseSrv Message Forum > Italiano > Computers - Italiano > Java - Italiano
 

 
Thread Tools Display Modes
  #1  
Old 07-15-2008
Kleidemos
Guest
 
Posts: n/a
Default Leggereda socket

import java.net.*;
import java.io.*;

class Mail
{
private Socket out_sock = null;
public Mail()
{
try
{
Socket out_sock = new Socket(InetAddress.getLocalHost(), 8080);
}
catch(IOException ioe)
{
System.out.println(ioe.toString());
}
}
public Mail(String name)
{
try
{
Socket out_sock = new Socket(InetAddress.getByName(name), 8080);
}
catch(IOException ioe)
{
System.out.println(ioe.toString());
}
}
public Mail(String name, int port)
{
try
{
Socket out_sock = new Socket(InetAddress.getByName(name), port);
}
catch(IOException ioe)
{
System.out.println(ioe.toString());
}
}
public void doClose()
{
try
{
out_sock.close();
}
catch(IOException ioe)
{
System.out.println(ioe.toString());
}
}
public Socket getSock()
{
return out_sock;
}

}

class Mailer
{
public static void main(String[] args)
{
Mail ml = new Mail();
try
{
DataOutputStream OUT = new
DataOutputStream(ml.getSock().getOutputStream());
DataInputStream IN = new
DataInputStream(ml.getSock().getInputStream());
OUT.writeChars("CIAO");
System.out.println("Letto " + IN.readLine());
}
catch(IOException ioe)
{
System.out.println(ioe.toString());
}
ml.doClose();
}
}


Perche IN nn mi legge quello che OUT ha scritto???


Tnk




Thread Tools
Display Modes

Forum Jump


All times are GMT. The time now is 01:35 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0