Solved

Socketing One Server n One Client

Posted on 2004-03-24
6
273 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 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

687 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