File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes chat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "chat" Watch "chat" New topic
Author

chat

che sy
Greenhorn

Joined: Mar 17, 2003
Posts: 1
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?
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
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
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to The Intermediate Forum...
[ March 17, 2003: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
You might want to take a look at IBM's Java Chat Server Tutorial.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: chat
 
Similar Threads
Help Regarding Cookies and session
URLyBird Optimistic record locking ?
keeping http clients up to date
Page Memory?
Simple socket client listening to data from server.