Solved

Socketing One Server n One Client

Posted on 2004-03-24
6
239 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
  • 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:
mayankeagle 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:mayankeagle
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:mayankeagle
ID: 10858172
>> i just found out i should hav implement thread

That is what I had suggested.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now