0% found this document useful (0 votes)
32 views1 page

Import Import Public Class Public Static Void Null Null Null

This Java code defines a Client class with a main method that establishes a socket connection to a server at IP address 127.0.0.1 on port 5000. It creates output streams to write the message "Hola Servidor" to the server, then closes the streams and socket connection before catching and printing any exceptions.

Uploaded by

Dante
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Import Import Public Class Public Static Void Null Null Null

This Java code defines a Client class with a main method that establishes a socket connection to a server at IP address 127.0.0.1 on port 5000. It creates output streams to write the message "Hola Servidor" to the server, then closes the streams and socket connection before catching and printing any exceptions.

Uploaded by

Dante
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

/home/hugo/NetBeansProjects/PACS/src/Cliente.

java
1importjava.io.*
2importjava.net.*
3
4publicclassCliente{
5
6publicstaticvoidmain(Stringargs[]){
7
8Socketsocket=null
9OutputStreamWritersalida=null
10BufferedWriterescribir=null
11
12StringipServidor="127.0.0.1"
13intpuerto=5000
14
15try{
16
17socket=newSocket(ipServidor,puerto)
18
19salida=newOutputStreamWriter(socket.getOutputStream())
20escribir=newBufferedWriter(salida)
21salida.write("HolaServidor")
22
23salida.close()
24escribir.close()
25socket.close()
26
27}
28
29catch(Exceptione){
30
31System.err.println(e)
32}
33}
34}
35

You might also like