Solved

Socketing One Server n One Client

Posted on 2004-03-24
6
261 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:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
print map entry 34 72
more than one jdk and one jre 1 50
How  Can  I  resolve   this  Error "java.sql.SQLException: Invalid column index" 4 49
Setup GlassFish 4 22
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

838 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