elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


  Mostrar Mensajes
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Re: sockets en: 17 Marzo 2010, 18:24 pm
Gracias nuevamente a los dos, ahora mismo me voy a poner a probar.
El tema de delegates tambien lo mirare y ya os contare mis progresos.

Gracias 
2  Programación / .NET (C#, VB.NET, ASP) / Re: sockets en: 16 Marzo 2010, 22:39 pm
Muchisimas gracias a los 2, le voy a echar un vistazo.

Se agradece vuestro interes

:-)
3  Programación / .NET (C#, VB.NET, ASP) / Re: sockets en: 16 Marzo 2010, 16:15 pm
Me podias poner un ejemplo simple de conexion multiple con TcpClient?
y como se realizaria con un array?

Muchas gracias a los 2 por la ayuda

Exacto, un socket por conexión, jjejej Raul deja el empeño con los sockets, FlashNet usa TcpClient :P es lo mismo pero más arreglado.. :D

Claro, amenos de que desees controlar mejor la conexión, pero no creo que sea tu caso.

Un saludo!
4  Programación / .NET (C#, VB.NET, ASP) / sockets en: 16 Marzo 2010, 01:10 am
Hola buenas, tengo un pequeño problema.
Quiero hacer un cliente al cual conecte a distintos servers simultaneamente y el comando que envie se envie a todos.
Hasta hay bien, el problema esta en que no consigo hacer varias conexiones a la ver solo una.
A ver si me podeis ayudar.

Gracias de antemano

aqui el codigo

Código:

Imports System.IO
Imports System.Net.Sockets
Imports System.Text
Imports System.Threading


Public Class Form1

    Private oTCPStream As Net.Sockets.NetworkStream
    Public Shared oTCP As New Net.Sockets.TcpClient()
    Private bytWriting As [Byte]()
    Private bytReading As Byte()

    Private oHebras As Thread


    Public Delegate Sub ParameterizedThreadStart(ByVal obj As String)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtNameFile.ReadOnly = True
        OpenFileDialog1.Filter = "File Txt |*.txt"
        OpenFileDialog1.Title = "Open File"
        OpenFileDialog1.Multiselect = False

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnArchivo.Click

        ComboBox1.Items.Clear()

        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            txtNameFile.Text = OpenFileDialog1.FileName

        End If
        If Not Trim(txtNameFile.Text) = "" Then
            Dim objReader As New StreamReader(txtNameFile.Text)
            Dim sLine As String = ""

            While sLine IsNot Nothing
                sLine = objReader.ReadLine()
                If sLine IsNot Nothing Then
                    ComboBox1.Items.Add(sLine)
                End If
            End While

            objReader.Close()

        End If

    End Sub

    Private Function ConnServ(ByRef VarIP) As Object

        If Not VarIP = "" Then
            Try
                System.Threading.Thread.Sleep(1500)

                oTCP.SendTimeout = 1500
                oTCP.Connect(Trim(VarIP), "8000")

                oTCPStream = oTCP.GetStream

                WriteData(Trim(txtUser.Text) & vbCrLf)
                System.Threading.Thread.Sleep(500)

                WriteData(Trim(txtPassword.Text) & vbCrLf)
                System.Threading.Thread.Sleep(500)

                WriteData("Hello Serv" & vbCrLf)
                System.Threading.Thread.Sleep(500)

                '  oTCPStream.Close()
                '  oTCP.Close()

            Catch ex As Exception
                MsgBox(ex.Message)

            End Try

        End If

        Return Nothing

    End Function

    Private Sub WriteData(ByVal sData As String)

        bytWriting = System.Text.Encoding.ASCII.GetBytes(sData)

        oTCPStream.Write(bytWriting, 0, bytWriting.Length)

    End Sub


    Private Sub btnConn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConn.Click

        Dim I As Integer
        Dim NewIP As String


        For I = 0 To ComboBox1.Items.Count - 1
            NewIP = (ComboBox1.Items(I).ToString)

            Dim t As New Thread(DirectCast(Function() ConnServ(NewIP), ThreadStart))
            t.Start()


        Next
    End Sub
End Class

Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines