Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm working on a program where part of it will be working as a chat between different people. I'm trying to figure out the best way to send and receive messages.

A PrintWriter or something similar won't work because the process will stop at the read() method while waiting for a message to be sent to it. I'd like to check to see if there is a new message, and if not, continue the execution.

I've seen some stuff about JMS, but I haven't done enough research to determine if it's up for this job.

Is JMS the best option for this, or is there a better way?

share|improve this question
    
Questions about software design decisions are fine here. –  user8 Jan 12 '12 at 12:00
    
Can you tell us more about the application? Is it a desktop application or a web application? Peer-to-peer, client-server, or some other architecture? –  Thomas Owens Jan 12 '12 at 12:16
    
Hello Thomas. Thanks for response but I have already decided to use JGroups. –  latusaki Jan 13 '12 at 23:19
    
I find JMS to be a solution from this discussion at <a href="stackoverflow.com/questions/1035949/… Overflow</a>. –  Srikanth Suresh Jun 24 '13 at 15:13
add comment

3 Answers

up vote 0 down vote accepted

You might want to check Netty.

Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.

share|improve this answer
add comment

You'll want to read up on Java's networking I/O but if you can't use Java 7 then you might want to look into this question/answer

HTH

share|improve this answer
add comment

If your project is a web project (like gwt or jsf), you can use reverse ajax to receive the messages in client side.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.