Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 10:49 PM
Member
 
Join Date: Jul 2007
Posts: 40
baltimore is on a distinguished road
Client TCP in Java
Hi, I can get a tcp server to communicate with a client, and thread this to simultaneously communicate with more clients, but i don't know how to get the clients to be able to hear each other, i cant seem to even loop through clients to send to when i want the server to reply

Does anyone know how to do this, or have a simple tutorial on it?
Threads really confuse me.

Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-01-2007, 04:29 AM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
Sorry, I am a bit new with Java, and I hope you don't mind me asking, but what's TCP?

May I suggest a linked list? where each client acts as a node?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-07-2007, 08:34 AM
Member
 
Join Date: Jul 2007
Posts: 40
mathias is on a distinguished road
Please check this code:

Code:
public class rServerRegistrar { public Thread[] cthreads; public rServerRegistrar(Thread thr) { cthreads=new Thread[1]; cthreads[0]=thr; } public void registerThread(Thread newthread) { Thread[] tempthreads=new Thread[cthreads.length+1]; for(int i=0;i<cthreads.length;i++) { tempthreads[i]=cthreads[i]; } tempthreads[cthreads.length]=newthread; cthreads=tempthreads; } public void deregisterThread(Thread delthread) { Thread[] tempthreads=new Thread[cthreads.length-1]; int count=0; for(int i=0;i<cthreads.length;i++) { if(delthread.getName()!=cthreads[i].getName()) { tempthreads[count]=cthreads[i]; count++; } } cthreads=tempthreads; } private void updateThreads() { int count=0; // First count the number of alive threads. for(int i=0;i<cthreads.length;i++) { if(cthreads[i].isAlive()) count++; } Thread[] temp=new Thread[count]; count=0; for(int i=0;i<cthreads.length;i++) { if(cthreads[i].isAlive()) { temp[count]=cthreads[i]; count++; } } } public Thread[] getClientThreads() { updateThreads(); // Return all except first thread. Thread[] temp=new Thread[cthreads.length-1]; for(int i=0;i<temp.length;i++) { temp[i]=cthreads[i+1]; } return temp; } }
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-09-2007, 10:18 PM
Member
 
Join Date: Aug 2007
Posts: 30
dmacvittie is on a distinguished road
Quote:
Originally Posted by Sircedric88 View Post
Sorry, I am a bit new with Java, and I hope you don't mind me asking, but what's TCP?

May I suggest a linked list? where each client acts as a node?
TCP is not Java Sircedric88, it's Transfer Control Protocol - one of the basic networking protocols your system uses.

Don.
__________________
Don MacVittie F5 Networks -
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Identify Client in Socket Client Server Application masadjie Networking 1 12-20-2007 11:18 AM
PPPoE client programming in java yeadam Networking 0 12-03-2007 02:14 AM
java client heyhey Advanced Java 0 10-29-2007 07:04 PM
Telnet client Java susan Networking 1 07-30-2007 11:59 PM
a problem about java mail client program lunarstyle AWT / Swing 6 06-02-2007 01:43 AM


All times are GMT +3. The time now is 02:09 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org