Estube haciendo un chat cliente servidor y bueno me base en un codigo base
y estube 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
Código:
http://rapidshare.de/files/38762592/Escritorio.rar.html
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