Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
How to communicate via socket with two computers in local network

I want to send data from a computer to another using sockets (Server/Client), I searched for a solution but I didn't found any one helpful, can anyone help me please.

here is my Server code :

import java.net.*;
import java.io.*;
class server
{
    public static void main(String arg[])
    {
    try
       {

        ServerSocket server = new ServerSocket(3006);
        Socket s = server.accept();
        System.out.println("connected!");   

        DataOutputStream dos = new DataOutputStream(s.getOutputStream());
        dos.writeUTF("Welcom to socket");
       }
    catch(Exception e){
        e.printStackTrace();     
       }
    }   
}

And this is my Client code: (192.168.1.5 is the Server's locale address)

 import java.net.*;
 import java.io.*;
 class client 
 {
    static InetAddress LocaleAdresse;
    public static void main(String arg[])
    {
       try
        {
        System.out.println("client execute");
        Socket s = new Socket("192.168.1.5", 3006);

        DataInputStream dis = new DataInputStream (s.getInputStream());
        String msg = dis.readUTF();
        System.out.println(msg);
        s.close();          
        }
            catch(Exception e){
            e.printStackTrace();
        }
    }
 }
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda