• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i Pass String in to Socket .....Urgent..urgent

 
Deepak B
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends
I am trying to make chat server application but I am facing problem �
How can pass a user name(string) to server .
I made a client socket with make a TCP/IP connection to server using
Socket s=new socket(host , port);
Actually my aim is to broadcast username to all user who currently login..Means as user login message will be display on the screen like �Denial has joined Room� here Denial is user name it may be differ .. Another thing is that I want to online user list in to applet that is only possible when I get username when new client connect to server.
I tried all the client socket option��plz help its urgent �.
Thnx in advance �
Deep
 
sushant sawant
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
theSocket=new Socket(e.inet,thePort);
in=new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
out=new PrintWriter(new OutputStreamWriter(theSocket.getOutputStream()),true)
create input and oupput stream like this
and then get ur username from textfield like
uname=tf1.getText();
and then send it to server with some initial string before it
so server can understand that it is username
like and get username from tht i think this much is enough.
out.println("#"+uname);
thanks 4 thanks
 
Deepak B
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx sushant
I got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic