Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

still not solved

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

//server side
import java.io.*;
import java.net.*;
class clientsoc1{
public static void main(String args[]) throws Exception
{
InetAddress i=InetAddress.getLocalHost();
String str=new String();
String strt=new String();
Socket soc=new Socket(i,4444);
System.out.println(soc.getInetAddress());
BufferedReader is=new BufferedReader(new InputStreamReader(soc.getInputStream()));
DataOutputStream os=new DataOutputStream(soc.getOutputStream());
BufferedReader bs=new BufferedReader(new InputStreamReader(System.in));
str=bs.readLine();
int i1=str.length();
strt=is.readLine();
os.writeChars(str);
os.write(10);//change made
System.out.println(strt);
os.flush();
is.close();
os.close();
soc.close();
}
}
//client side
import java.net.*;
import java.io.*;
class Serversoc1{
public static void main(String args[]) throws Exception
{
String str1=new String();
ServerSocket scos=new ServerSocket(4444);
Socket soc1=scos.accept();
System.out.println(soc1);
BufferedReader br=new BufferedReader(new InputStreamReader(soc1.getInputStream()));
DataOutputStream ds=new DataOutputStream(soc1.getOutputStream());
System.out.println("on server now");
str1= br.readLine();//change done
System.out.println(str1);// prints on the server side
ds.writeChars(str1);
ds.write(10);//change done
ds.flush();
br.close();
ds.close();
soc1.close();
}
}
it is still not working.please try it out.i've been working on it for a long time.but still ,if the message is not send back to the client
then it works properly the message is printed on the server side.
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your client, you are still trying to read from the server Before you send the string to the server.
 
anuj khanna
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well sorry to say i've made the change still its not working.did u tried the code on machine.well it should be working still it isn't don't know where the problem lies.???
 
anuj khanna
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well sorry to say i've made the change still its not working.did u tried the code on machine.well it should be working still it isn't don't know where the problem lies.???
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a matter of fact
The client

The Server

Blank lines and comments can help regardless of your level of understanding

------------------
Hope This Helps:)
Carl Trusiak
 
anuj khanna
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot.i'll keep it in mind.i'm highly grateful to you.thanks for taking the pain.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic