JavaScript - Pasar Esto de VB A JS

 
Vista:

Pasar Esto de VB A JS

Publicado por David (1 intervención) el 16/12/2012 04:37:58
'Hay que escuchar en el puerto correcto debe ser el mismo que el puerto del cliente se quiere conectar el.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Const portNumber As Integer = 5555
        Dim tcpListener As New TcpListener(portNumber)
        tcpListener.Start()
        Console.WriteLine("Esperando Conexión...")
        Try
            'Aceptar la conexión del cliente en espera y retorno
            Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
            Console.WriteLine("Conexión aceptada.")
            ' Get Obtener el flujo de
            Dim networkStream As NetworkStream = tcpClient.GetStream()
            ' Leer la secuencia en una matriz de bytes
            Dim bytes(tcpClient.ReceiveBufferSize) As Byte
            networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
            ' Volver a los datos recibidos desde el cliente a la consola.
            Dim clientdata As String = Encoding.ASCII.GetString(bytes)
            Console.WriteLine(("El Cliente Envió: " + clientdata))
            Dim responseString As String = "Conectado al servidor."
            Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
            networkStream.Write(sendBytes, 0, sendBytes.Length)
            Console.WriteLine(("Enviado Mensaje > " & vbNewLine + responseString))
            'Cualquier comunicación con el cliente remoto utilizando el TcpClient puede ir aquí.
            'Cerrar y TcpListener TcpClient.
            tcpClient.Close()
            tcpListener.Stop()
            Console.WriteLine("<Enter> Para salir Salir")
            Console.ReadLine()
        Catch e As Exception
            Console.WriteLine(e.ToString())
            Console.ReadLine()
        End Try
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder