• 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

chat

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm creating a project for a single client application in java. what would i do to be able to get the data sent by the client and to transmit data? do you have a sample code for this?
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy,
You'll need to use Sockets (java.net package), Streams (java.io), and probably Threads to do this. It's a little too advanced for this forum, though, so I'm just giving you the overview:
Client makes a Socket connection to the server.
Server has a ServerSocket to accept client connections.
Client gets an input stream and output stream from the Socket. Client sends data to the server over the output stream and receives data from the server using the input stream. There are many types of input and output streams, but you might want to look at sending serialized objects using ObjectInputStream and ObjectOutputStream. This can often be eaiser than other streams, but it depends on the kind of data you need to send and receive.
Server does basically the same thing, gets input and output streams from the Socket connection, and sends data and receives data through these streams.
I know there are a couple of books that have chat code in them, but I can't think of the names right now.
good luck,
Kathy
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to The Intermediate Forum...
[ March 17, 2003: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to take a look at IBM's Java Chat Server Tutorial.
 
reply
    Bookmark Topic Watch Topic
  • New Topic