[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Socketing One Server n One Client

Posted on 2004-03-24
6
Medium Priority
?
281 Views
Last Modified: 2010-03-31
i hav this applet which has

Quote:
init ()
{
//interface codings
}
void actionPerformed()
{
if (e.getActionCommand=="Host")
{
// i wanted to create serverSocket here but it just seems to be hang here, listening connection, and i couldnt click on any GUI component
}
elseif (e.getActionCommand=="Join")
// so as happen to this after i hav created socket.
}


and how am i suppose to write the socket code??
in order to let the server always listen client, and able to send msg to client
same goes to client, always listen to server, and able to send msg to server

my source's at : http://www.geocities.com/giasens/JavaBingo.zip 
corresponding file in the zip: bing2.java

thanks...
0
Comment
Question by:SaiSeng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10674150
A call to accept() on ServerSocket is blocking, i.e. since you're doing it in your UI code, it WILL make your applet appear to hang.

What exactly are you trying to do?
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 500 total points
ID: 10674376
>> in order to let the server always listen client, and able to send msg to client

Put it in a loop. Use threads.

>> same goes to client, always listen to server, and able to send msg to server

Same thing goes there.

>> but it just seems to be hang here, listening connection, and i couldnt click on any GUI component

I guess your Applet would also need to be signed if you want it to communicate remotely.

http://mindprod.com/jgloss/signedapplets.html
http://personal.vsnl.com/sureshms/javasign1.html (courtesy objects)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10857939
Please proceed with that recommendation.
0
 

Author Comment

by:SaiSeng
ID: 10857952
sorry ... i just found out i should hav implement thread. btw, thanks :)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10858172
>> i just found out i should hav implement thread

That is what I had suggested.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question