|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Sep 2002
Città: vinci-spicchio
Messaggi: 530
|
socket e java
Io ed un mio compagno di classe abbiamo sviluppato il gioco della dama in java con l'utilizzo dei socket ed abbiamo creato il client ed il server, ora il gioco funziona però il problema è che al costruttore del socket gli passiamo il numero della porta e il nome del server all'interno della rete, mentre noi vorremmo passargli l'indirizzo ip del server, mi potreste indicare la sintassi e quali classi e quale costruttore della classe socket devo utilizzare.
Grazie
__________________
Intel Pentium DualCore E2140 1,60 GHz , Asus P5LD2 R2.0,Sapphire x600xt 128Mb,hauppauge winTV,2x256Mb Ddr2 Vitesta 533Mhz,western digital caviar 160gb, seagate 20gb 5400giri, maxtor 40gb 7200giri, dvd+-rw gigabyte(BTC) 4x,Samsung writemaster dvd duallayer 18x , edimax wireless<-->router D-link G604T. |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 5707
|
Se usi il nome dell'host:
Codice:
try
{
String host = "www.xyz.com";
int port = 1000;
Socket socket = new Socket(InetAddress.getByName(host), port);
}
catch (UnknownHostException e) {}
catch (IOException e) {}
Codice:
try
{
byte[] ip = new byte[]{192, 168, 0, 1};
int port = 1000;
Socket socket = new Socket(InetAddress.getByAddress(ip), port);
}
catch (UnknownHostException e) {}
catch (IOException e) {}
|
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Sep 2002
Città: vinci-spicchio
Messaggi: 530
|
grazie ora provo
__________________
Intel Pentium DualCore E2140 1,60 GHz , Asus P5LD2 R2.0,Sapphire x600xt 128Mb,hauppauge winTV,2x256Mb Ddr2 Vitesta 533Mhz,western digital caviar 160gb, seagate 20gb 5400giri, maxtor 40gb 7200giri, dvd+-rw gigabyte(BTC) 4x,Samsung writemaster dvd duallayer 18x , edimax wireless<-->router D-link G604T. |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 18:40.



















