That means it couldn't find the destination. I noticed you are using command line args. Do you know how to get those? It won't run unless you have an argument to the right destination.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Another way would be using a bufferedreader to get input from the user. But why not jut compile with the correct arguments? You know how to do that right?
javac ProgramName.java
java ProgramName argument1
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Ok so its 9 am...and still no sleep so i wont go thru all this code but just a quick little two cents worth. Its a chat program, the way i normally do these (and there might be others) is to use 2 ports (send / receive) and multiple threads. 1 thread for gui, 1 thread for functionality, and 1 thread for a "ConnectionListener".
The program that is listening for a connection (chat client to connect) needs to create a ServerSocket. e.g. "ServerSocket myServerSocket = new ServerSocket( << a port # >>);"
That port is now locked on your system so unless you start a client (with listener) on a different port you will encounter problems (or at least i did when i wrote my first chat program).
A quick run thru on how i believe ServerSockets work. They listen on a port and when a connection is attempted with "Socket mySocket = MyServerSocket.accept();" it makes a connection (socket) on a port (other then the one being listen upon). Thus if you want to accept multiple connection. e.g. chat with more then 1 person at a time put the code to accept connections in a loop to keep on listening for more connections.
if you dont get this fixed i'll take a look at your code after i get some sleep.
p.s. does "InetAdress.getLocalHost().getHostAddress()" accomplish what you needed for the ip?
Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
Hi everyone,
Your error is due to the fact that you have no server. Read up on sockets and serversockets to improve your skills
Richard West
freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
lijumon, make your own thread and do not attempt to hijack other threads.
gokul, what is "aik6 - my system name"? It might know how to connect to 'localhost' or an IP address, but unless your home network is setup to recognize aik6 in that manner it probably won't know what the heck that address is.
Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
Well, you are off to a good start by choosing to hijack an old thread in the Java forum to ask someone to walk you through it.
Post your question in the C++ or C# forum and don't be surprised if you get very general answers to such a general question.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
hey all,
I was also thinking about a chatting application. However I am kinda new to programming. Would someone pliz guide me on how to go about it using C++ or C#(i've gone through the basics of C++). Can the chatting "operation" be achieved by scripting also?
If you want to do chat application in C++ or C# you should ask this question in appropriate section of our forum
C++ here
C# here
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902