Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!