PDA

Click to See Complete Forum and Search --> : java, vb, and winsock


nswan
Feb 5th, 2002, 03:52 PM
hi,

I have to write a program in java and a program in VB that can communicate together. I know how to use winsock in VB but can it be used in java.
If the answer is yes, does anybody have any code. The VB will be the server(listen) and the Java program will be the one connecting.


Thanks for any help
Nick

billrogers
Feb 5th, 2002, 03:56 PM
No the winsock control is activeX and that is microsoft. You need to use the socket class that comes with java.

The good news is that they are just that sockets and winsock and java can communicate no problems, but you will have to learn about them in java. :)

Cudabean
Feb 5th, 2002, 04:19 PM
Socket documentation (along with all other important Java API information) can be found at:
http://java.sun.com/j2se/1.3/docs/api/index.html
Scroll down on the left navigation bar (where it says "All Classes") until you get to Socket. You'll also need to look at SocketImpl here as well.

It says that you can use the following constructor:
Socket(InetAddress address, int port)

Don't forget to declare this at the top:
import java.net.Socket;

It also says that to actually make a connection, you'll need to use the SocketImpl class (so specify import java.net.SocketImpl; at the top also)

This should get you in the right ballpark.

cudabean