Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java and VB Socket Communication

843790Mar 13 2008 — edited Mar 16 2008
Hi All,
I am developing a prototype which need do get some data from Java to VB application. I created server socket in java, My VB application is sending data to the same port what java is running.
The Java program able to recognized some data in coming to the port. but BufferedReader, readLine() not able to read the bytes. Please any one help me to resolve this problem.
Java Code :
public class KnockKnockServer {

public static void main(String[] args) throws IOException {

ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(4444);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(1);
}

Socket clientSocket = null;
try {
clientSocket = serverSocket.accept();
} catch (IOException e) {
System.err.println("Accept failed.");
System.exit(1);
}

PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
try{
do{

String headerLine = in.readLine();
if(headerLine==null ||headerLine.equals("\r\n") ||headerLine.equals("") ||headerLine.equals("null")){ System.out.print("");
continue;
}else{
System.out.print(headerLine);
}

} while(true);
}catch(Exception e){
e.getStackTrace();
}


out.close();
in.close();
clientSocket.close();
serverSocket.close();
}
}

My VB code :
Winsock.Close

If Winsock.State = sckConnected Then
MsgBox "Connected with server"
End If
'Winsock.Protocol = sckTCPProtocol
Winsock.RemoteHost = "insgb0333"
Winsock.RemotePort = 4444
Winsock.Connect


If Winsock.State = sckConnected Then
MsgBox "Connected with server"
End If

Winsock.SendData "test"
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 13 2008
Added on Mar 13 2008
4 comments
206 views