aspose file tools*
The moose likes Distributed Java and the fly likes A Problem with with Java network programming Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "A Problem with with Java network programming" Watch "A Problem with with Java network programming" New topic
Author

A Problem with with Java network programming

Farhad Rahmati
Ranch Hand

Joined: Dec 16, 2010
Posts: 96
Hi

I am just trying to make a multithread server with two ports. one listening to one group of clients and the second for another group of clients. I know we can solve this with multithread but I couldn't find a way. can anyone please help me with a simple code.

thanks

Farhad
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

you use socket programming with the thread to solve your problem.


SCJP 6- 91%, IBM DB2, IBM RAD Certified
Farhad Rahmati
Ranch Hand

Joined: Dec 16, 2010
Posts: 96
Thanks, I know how to use sockets and I know multithread, but my problems is I have two server sockets listening for clients. I have two group of client which are cahiers and cooks. cashiers add orders and cooks removes orders.

I have connected the cashiers and It works

but when I connect cooks it stops working, the poblem is I don't know how to use multithread here.

I have three threads one my main thread, second cashier handler and third cook handler

I can't decide about the connection. I am just trying to say ( if cashiers connected run cashier handler else run cook hanlder)

Is it possible?

thnx
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

I think this discussion will fit better in the Distributed Java forum... so, let's move it!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Alex Hurtt
Ranch Hand

Joined: Oct 26, 2010
Posts: 98
It sounds like you at least have a start. Post us the relevant code where you are getting stuck...If a picture is worth 1000 words, a line of code is worth at least a half dozen posts when it comes to getting answers to coding problems.
Farhad Rahmati
Ranch Hand

Joined: Dec 16, 2010
Posts: 96
Hi Alex

Thank you very much, I like your comment

Finally I got it solved, I will let you know, If I found any other problem.


Cheers
Farhad
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

Howdy, Farhad!

We're glad you got it working! Can you please show us your solution? It's just that it helps other people that are also facing the same problem. Also, if in the future someone seaches for something similar on Google, then posting the solution will help this person as well.
Farhad Rahmati
Ranch Hand

Joined: Dec 16, 2010
Posts: 96
Roberto

Ofcourse I can share it, I did it with the help of this site and examples which were posted, I used many examples. this community was really helpful

I appreciate this.

But Please let me submite my assignment, I promise I will share my code here. It would be my pleasure if I could help one person, although I am not an expert.

Just let me submite my assignment. My tutor might think of plagiarism of he find the code here.

Sorry about that now, But I give you my word.

Cheers
Farhad
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

Farhad Rahmati wrote:But Please let me submite my assignment, I promise I will share my code here.


Are we talking about the SCJD assignment here? If so, then unfortunately you won't be able to do so since we are not allowed to post solutions of this assignment here.

I thought we were talking about a regular problem here, champ. Sorry for the confusion! Or, if this is a regular problem, then you can go ahead and post your code here!
Alex Hurtt
Ranch Hand

Joined: Oct 26, 2010
Posts: 98
Farhad Rahmati wrote:My tutor might think of plagiarism of he find the code here.


Except that it would be posted with your name being attributed as the author of the post so...if your tutor were to see that and still assume you plagiarized it then you should probably consider finding a slightly smarter tutor.
But no worries, glad you were able to figure it out.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A Problem with with Java network programming