I'm currently trying to write a chat program, and a server program acting manager for the chat clients.
Evrything works just fine until I reach the chat part, the client can connect to the server, but it seems that the server never gets the message.
here is the code:
WARNING: At first i tryed to keep the coding in nice order and do evrything by the book, but as I've tryed to fix it MANY times, it ended up looking sort of like a mess. I've also done quite some things against the "rules" such as doing no recovery code to an exception.
You create a ServerSocket and start listening on it.
Then, when a client comes in, the server accepts the client,
writes a message and sets the client socket (sock) to null.
You already have a ClientHandler but you are not using it.
Your server should run in loop after setting up the listen
For each incoming client it should then create a new
ClientHandler and pass the client socket (Socket)
to that client handler.
Then it will work.
Another problem is:
your server and client are Java programs running in
a JVM each. When closing the window, the JVM does not
get terminated (System.exit()).
You can fix that by adding
let's assume you are connected to the Net via DSL.
Event hough this connection is durable your provider
probably issues you a new IP address every now and then.
Unless you are using a static IP address from your ISP or
dynamic DNS the IP address your friends use to connect
So this is how we can get to your front door.
Then there is the firewall.
You say it works from your laptop. So I assume you are connecting
from your laptop to a 192.168.x.x or 10.x.x.x address.
These are private addresses and cannot be routed to the Net.
You will have to enable port forwarding on the firewall for port 5323 and
have it pointing to the IP address you can connect from your laptop.
This should be the same address used by your server ("myIpAddress").
I think I have just to try make the server better, and acept that I can't connent with people from the outside world. I don't really know much about internet related stuff like DMZ, and beside from that, I can't even connect to my router as I don't have the password for it.
But I'll try to improve the server.
By the way, i find this forum really helpfull and friendly, thansk for the nice responses
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees: