We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Socketing One Server n One Client

SaiSeng
SaiSeng asked
on
Medium Priority
300 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...
Comment
Watch Question

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?
Principal Technologist
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Mayank SPrincipal Technologist
CERTIFIED EXPERT

Commented:
Please proceed with that recommendation.

Author

Commented:
sorry ... i just found out i should hav implement thread. btw, thanks :)
Mayank SPrincipal Technologist
CERTIFIED EXPERT

Commented:
>> i just found out i should hav implement thread

That is what I had suggested.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.