• Jueves 28 de Marzo de 2024, 15:04

Autor Tema:  Sondeo Y Escucha Tcp  (Leído 1651 veces)

txemo

  • Nuevo Miembro
  • *
  • Mensajes: 16
    • Ver Perfil
Sondeo Y Escucha Tcp
« en: Lunes 9 de Agosto de 2004, 12:54 »
0
Hola, necesito que mi aplicación esté constantmente atendiendo peticiones de conexion en un puerto. El problema no es codificar estas peticiones con sockets, el problema es que no tengo  ni idea de como hacerlo para que esté ejecutandose siempre ese subprograma y la aplicación, que es una aplicación normal de windows se ejecute también normalmente.

Alguien sabe como se puede hacer?

bgomez

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Re: Sondeo Y Escucha Tcp
« Respuesta #1 en: Miércoles 22 de Septiembre de 2004, 17:08 »
0
Apenas inicio en esto, pero te puede ayudar este scrip

Const portNumber As Integer = 13
Dim tcpListener As New TcpListener(portNumber)

tcpListener.Start()

Console.WriteLine("Waiting for a connection....")

Try
   
   'Accept the pending client connection and return a TcpClient initialized for communication.
   Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
   Console.WriteLine("Connection accepted.")
   
   Dim networkStream As NetworkStream = tcpClient.GetStream()
   
   Dim responseString As String = "You have successfully connected to me."
   
   Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
   networkStream.Write(sendBytes, 0, sendBytes.Length)
   
   Console.WriteLine(("Message Sent /> : " + responseString))
   
   'Any communication with the remote client using the TcpClient can go here.
   '
   '//////
   'Close TcpListener and TcpClient.
   tcpClient.Close()
   tcpListener.Stop()

Catch e As Exception
   Console.WriteLine(e.ToString())
End Try
[C#]
const int portNumber = 13;
      TcpListener tcpListener = new TcpListener(portNumber);

      tcpListener.Start();

Console.WriteLine("Waiting for a connection....");
 
try{

Saludos de Guatemala
Byron Gomez