Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package client_sever;
- import java.io.*;
- import java.net.*;
- public class Sever {
- public static void main(String[] args) {
- try{
- ServerSocket ss = new ServerSocket(3306);
- Socket s =ss.accept();
- DataInputStream dis=new DataInputStream(s.getInputStream());
- String str = (String)dis.readUTF();
- System.out.println("Message = "+str);
- ss.close();
- }
- catch(Exception e){
- System.out.println(e);
- }
- }
- }
- package client_sever;
- import java.io.*;
- import java.net.*;
- public class client {
- public static void main(String[] args) {
- try{
- Socket s = new Socket("localhost",3306);
- DataOutputStream dout=new DataOutputStream(s.getOutputStream());
- dout.writeUTF("Hello Server");
- dout.flush();
- dout.close();
- s.close();
- }
- catch(Exception e){
- System.out.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment