i made a server in java and now when i send data from visual basic, nothing happens because i have no method to receive the data and i would like to get one. i tried google and found nothing.
how to receive data in java from vb?
Printable View
i made a server in java and now when i send data from visual basic, nothing happens because i have no method to receive the data and i would like to get one. i tried google and found nothing.
how to receive data in java from vb?
How are you sending the data and how are you attempting to receive it?
Are both the programs running on the same server? I assume not since you mention you're using java on your server. You may want to look into web services.
the server is programmed in java, i send data from vb6 with winsock by using a code like this: winsock1.sendData(data)
and i want the server to read the data and print it to the console.
use Server Sockets.. There are lots of tutorials online. Just google the topic
incase you didnt read what i wrote: "i tried google"
So you've seen these results and non of them works for you
i quit searching for this now, google wont show the same results up for every computer.
everything i want is just to get the message from the client.
Ok, this code should work. I haven't tried it and I'm not sure if it's exactly what you need.But I still hope its usefulCode:import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
public class Test {
public static void main(final String[] args) throws IOException {
final ServerSocket serverSocket = new ServerSocket(1234);
serverSocket.setReceiveBufferSize(1024 * 8);
final BufferedReader reader = new BufferedReader(new InputStreamReader(
serverSocket.accept().getInputStream()));
final StringBuffer buffer = new StringBuffer();
while (reader.ready())
buffer.append(reader.readLine() + "\n");
System.out.println(buffer.toString());
}
}
not sure, when i connect to it, the program stops running and says "press a key to continue..." or something like that and stops running.
I forgot to mention that 1234 is the port number. Feel free to change it to whatever appropriate.
i know that... i changed the port to the one i want to and when i connect to the server with my client, the server stops running.
Hello budy..
i have one suggestion for this situation, u should write send method from server which is coded in java and write get method at client side which is coded in VB language, yet i have never tried it but just find more solution from www.sun.com, if any problem occure.
good idea... almost gave up hope making this...
thanks