• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnx sushant
I got it
 
reply
    Bookmark Topic Watch Topic
  • New Topic