• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Socketing One Server n One Client

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
SaiSeng
Asked:
SaiSeng
  • 3
1 Solution
 
Tommy BraasCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
>> 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
 
Mayank SAssociate Director - Product EngineeringCommented:
Please proceed with that recommendation.
0
 
SaiSengAuthor Commented:
sorry ... i just found out i should hav implement thread. btw, thanks :)
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> i just found out i should hav implement thread

That is what I had suggested.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now