This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Problem with with Java network programming

 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you use socket programming with the thread to solve your problem.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this discussion will fit better in the Distributed Java forum... so, let's move it!
 
Alex Hurtt
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic