boba fett

+ Follow
since Jul 19, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by boba fett

I am with Omar. First by UNIX "PORT", do you mean an IP port that you have specified thru your Socket object and opened? Or some Unix utility "PORT" command or shell script. Is the "PORT" a java or unix topic for you. Well if it is a Java IP Port you have opened thru a socket or serversocket then you probally have a procedural issue. I mean that you need to check and make sure your logic is not prematurely exiting your execution before what you want to finishe is done, there fore closing the connection (socket) on that IP Port on your machine, while you may still request more reads, and its closed already. Do you have the whole operational execution based in the socket object, or in some other method? Can you post more info?
20 years ago
First off how much time and effort do you wish to put forth to this. If none then go and find another already done chat program.
Well the others have dirrected you to the right path, but here is what I would reccomend. Use the* pack. Make a server and client side programs.
You would have two programs, the server and the clients.
Create a ServerSocket for a server process. Have that guy except new users, and stores their IPs and user names when they logg in. Now once someone requests another user, put the username and IP in the same little lookup routines. Basically when someone asks for a user by username, all you have to do is look at tall the logged in usernames, and just reroute the IPs to them so they can establish a connection and chat. Or you handle all of the rerouting on the sever to keep IPs from being sent to other users, your choise!
Now on the client side you should set up a Socket object to connect to the Fixed IP location of the Server for a lookup and checkin. Now also give them a serversocket listener (a method on a specified port that accepts() data then reacts). Once you have decided how to route them, by security reasons, now all that is left is to do simple Java I/O back and forth thru the sockets, then route it to a small GUI or console based system. Lots of work, depends what you want this for, there are no easy solutions to anything in life, but hope that helped
This is the method call on your thread. I hate it when people sometimes give me all but the actual syntax. So here it is

void setDaemon(boolean on)
Marks this thread as either a daemon thread or a user thread.
Your thread problem appears to be how to keep a thread running after a program exits? Well your solution is actually hidden in what main is. Main is a thread in the process. It is a DEAMON. Well once main exists, your program exits even if you have threads running right. Well the solution is there is a mehtod call in the thread class, look into the API. It is something like SetThreadToDEAMON(). Well once you set a thread to deamon, then the actually program will not exit, hence the program will not die till the thread eventually dies. But in the background the execution of your normal main() procedural program will have finished, but the program will not die till the thread does. This is the only way. Threads in JAVA are threads in the VM. Threads in Windows or so on are actually independent processes, that have their own space in the kernel processes space. So simple assign that thread to a DEAMON and the thread will run even after the main() has finished executing.