How do sockets work in java? I have only previously been exposed to the VB winsock control, which receives data automatically as an event. From a tutorial i've seen, it looks like all incoming data has to be manually read using a bufferedreader, perhaps using a continuous loop, is that how it goes?
The URL class can be used also. All you do is invoke openStream() on an instance of a URL to get an InputStream which can then be used to read the contents of the URL. You can also invoke openConnection() on A URL instance to get an URLConnection so you can read/write.
For lower level communication i would use Sockets though. Say if you were writing a client-sever appliction and you wanted to implement some sort of custom protocol.
Yes, I'm writing a client-server application. The server is actually in VB, I just need to get a working client apllication going. I'm only sending and receiving simple text strings, so which method would work best, and can you give me a code example?
I can't give you a code example, but I would go with polling the sockets as CB suggested. I tried making a simple chat program and looping continously readinng from the socket even if it was null was very slow and usually locked up the application.
Nove why not just write the client in VB? You already have the server side code written. I wouldn't add to the complexity by writing a cross language program until i knew exactly both sides.
Well, I have written the client in VB, but it'll be much easier on the user if they can just log on through a web browser. This also gives me a good chance to get some Java learning in.
Here is a small applet that I wrote for one of my web pages for our Help Desk. It may be capable of doing a bit more than you intend, but it should get you started.
It 'talks' to a C server, but I have done the same thing with VB. It isn't necessary, but I put the variables to be sent/redeived in classes that match the C struct or VB UDT. It's helpful when you dealing with very large complicated structures.
You will have to convert any Longs and Integers in your VB app to/from network-byte-order (big-endian). The read/write methods in the Java classes automatically do the conversions.