Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

chat - socket for client

 
Jonathan Klein
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to programm a small chat-programm for my homepage for practice. As my host has no Java support I was thinking that an applet would be the best and only solution.
So I was thinking about realising it - but when it comes to the connection from the client to my applet I was wondering what Ip-address I should hand over to the socket object. Is it location of the applet as InetAddress and what about the port?
I hope you can help me with that
best regards
Jonathan
ps: sorry for my english
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, you will have to read about applet security. By default, an applet is not allowed to open up a network connection to anyplace other than the web server from which it was downloaded. This means you could set up a chat *server* that runs on the same machine as the web server, and all your client applets could communicate with it. However, this requires that you are in fact able to deploy a java application on the web server, and it doesn't sound like you are able to do that.
So, you might try a simple client-to-client connection. Two different computers, each running your applet within a browser. The IP address is that of the other computer you want to connect with. The port is up to you. You should read up on the java.net package classes and understand how to open sockets and send and retrieve data over the network.
But if you do this, you will have to sign your applet, since you are now trying to connect to an IP address that is different from the web server, and by default Java will not allow this - you'll get a security exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic