• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

chat - socket for client

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
ps: sorry for my english
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.
    Bookmark Topic Watch Topic
  • New Topic