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) / VB.NET sockets cliente-servidor en: 8 Marzo 2008, 13:29 pm
Hola a todos
estuve haciendo un chat cliente servidor y bueno me base en un codigo base
y estuve probando, cuando termine al probarlo con un amigo no me funcionaba
el puerto que tuiliza es el 6112 y se encontraba abierto
y ademas no tenia firewall. me funciona perfectamente en localhost mas no en inernet.
alguien si me puede ayudar se lo agradeceria aca dejo el codigo del cliente y el cliente y servidor compilado.

saludos

--CLIENTE Y SERVIDOR
Código:
http://rapidshare.de/files/38762592/Escritorio.rar.html

--CODIGO DEL CLIENTE
Código:
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
    Dim client As TcpClient
    Dim data() As Byte

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart.Click
        If txtserver.Text = "" Or txtport.Text = "" Or txtnick.Text = "" Then
            MsgBox("Ingrese Datos para la Conexion")
            Exit Sub
        End If

        If btnstart.Text.Trim = "START" Then
            MsgBox("in")
            Try
                '---connect to server
                client = New TcpClient
                client.Connect(txtserver.Text.Trim, txtport.Text.Trim)
                ReDim data(client.ReceiveBufferSize)
                SendMessage(txtnick.Text)
                '---read from server
                client.GetStream.BeginRead( _
                   data, 0, CInt(client.ReceiveBufferSize), _
                   AddressOf ReceiveMessage, Nothing)
                btnstart.Text = "OUT"
                btnsend.Enabled = True
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        Else
            'DESCONECTA
            Disconnect()
            btnstart.Text = "START"
            btnsend.Enabled = False
        End If


    End Sub

    Private Sub btnsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsend.Click
        SendMessage(txtmsg.Text.Trim)
        txtmsg.Clear()
    End Sub

    Public Sub Disconnect()
        '---DESCONECTA
        Try
            client.GetStream.Close()
            client.Close()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Public Sub ReceiveMessage(ByVal ar As IAsyncResult)
        Try
            Dim bytesRead As Integer
            bytesRead = client.GetStream.EndRead(ar)
            If bytesRead < 1 Then
                Exit Sub
            Else
                Dim para() As Object = {System.Text.Encoding.ASCII.GetString(data, 0, bytesRead)}
                Me.Invoke(New delUpdateH(AddressOf Me.UpdateH), para)
            End If
            client.GetStream.BeginRead( _
               data, 0, CInt(client.ReceiveBufferSize), AddressOf ReceiveMessage, Nothing)
        Catch ex As Exception
        End Try
    End Sub

    Public Delegate Sub delUpdateH(ByVal str As String)
    Public Sub UpdateH(ByVal str As String)
        rtxt.AppendText(str)
        txtmain.AppendText(str)
    End Sub

    Public Sub SendMessage(ByVal message As String)
        Try
            '---send a message to the server
            Dim ns As NetworkStream = client.GetStream
            Dim data As Byte() = System.Text.Encoding.ASCII.GetBytes(message)
            '---send the text---
            ns.Write(data, 0, data.Length)
            ns.Flush()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

End Class
2  Programación / Programación Visual Basic / Re: msn en visual basic en: 28 Junio 2006, 03:04 am
oye franco te voy a matar!!!! cambia tu firma !!!!
existe el Interdev User Bar !!! esta en interdev XD
bueno el proyecto es buenisimo buen aporte XD
de ahi terminamos los iconos loca  ;D
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines