connect by socket Java server and .NET client

0

Hi everyone, I'm trying to connect two computers per socket ... the server has services in java and the client is in visual basic ... I downloaded libraries to recognize java methods and my class that calls the socket is like this :

Public Shared Sub CallSocket(ByVal strJSON As String)
    Dim sentence As String = ""
    Dim respuesta As String = ""
    Try
        Dim inFromUser As New BufferedReader(New InputStreamReader(java.lang.System.in))

        '1 crea el socket y se conecta
        Dim clientSocket As New Socket("192.168.1.2", 15000)

        '2 se consigue el canal de entrada
        Dim inFromServer As New BufferedReader(New InputStreamReader(clientSocket.getInputStream()))

        '3 se consigue el canal de salida
        Dim outToServer As New DataOutputStream(clientSocket.getOutputStream())

        '4Se pasa el JSON a la variable sentence
        sentence = strJSON

        '5. El método java.io.DataInputStream.writeBytes (String s) escribe un byte en el flujo subyacente
        'como un valor de 1 byte. El contador se incrementa en 1 en la ejecución exitosa de este método.
        outToServer.writeBytes(sentence & "\n")

        respuesta = inFromServer.readLine() ''en esta linea se queda y ya no hace nada mas

        java.lang.System.out.println("FROM SERVER: " & respuesta)

        Dim pdfstr As String = respuesta.SubstringBetween("{\" & Chr(34) & "pdf" & "\" & Chr(34) & ":\" & Chr(34), "\" & Chr(34) & ",\" & Chr(34))
        Dim pdf As Byte() = getDecoder().decode(pdfstr)

        If pdf IsNot Nothing Then
            Dim File As New File("prueba" & DateTime.Now.Millisecond & ".pdf")
            Dim FileOutputStream As New FileOutputStream(File)
            FileOutputStream.write(pdf)
            ' FileOutputStream.write(pdf)
            FileOutputStream.flush()
            FileOutputStream.close()

            Desktop.getDesktop().open(File)
        End If
        clientSocket.close()
    Catch ex As Exception
        java.lang.System.out.print(ex.Message())
    End Try 

When I get to the line == > answer = inFromServer.readLine () to get a response from the server the program just waits and does nothing else

I hope you can help me with this problem

    
asked by edusito87 27.10.2018 в 06:09
source

0 answers