Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

NIO versus NET?

Thread view: 
XELON - 04 Mar 2006 17:38 GMT
Hi,

I'm working on an instant messaging program. It is part of my senior
project. I want to write the server with Java. But I can't decide to
use ServerSocket or Channels(NIO). I searched google and find some
information. They say using NIO is more efficient. But the client side
of software might be written with C, C# or Java. If I use nio instead
of net package, can i connect the server with TCP via any programming
languages' TCP libraries?

And which method do you advice? (nio or net)

To send the message through server, there must be 2 established
connection between users and server. Server is going to keep the
established connections with ArrayList or Vector. If a user(say usr1)
sends a message to another user(say usr2), first the server takes the
message from usr1 and finds the name of recipient from message, and
find the connection between server and usr2 on Vector or ArrayList with
user name. And sends the message to usr2. Is this a correct way of
messaging?

Thanks
Thomas Hawtin - 04 Mar 2006 19:15 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> of net package, can i connect the server with TCP via any programming
> languages' TCP libraries?

It's all TCP/IP on the wire. It doesn't matter how each end is written.

> And which method do you advice? (nio or net)

Go for java.net. There are ways java.nio can be more efficient (in terms
of CPU cycles), but it is unnecessarily complicated for most problems.

> To send the message through server, there must be 2 established
> connection between users and server. Server is going to keep the
[quoted text clipped - 4 lines]
> user name. And sends the message to usr2. Is this a correct way of
> messaging?

Sounds reasonable. However, if you have the same thread that reads the
message from the sender also write to the recipient, any delays relaying
the message will prevent the next message being read. So it's normal to
have two threads for each connection.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.