Login Register






There was a very particular style of DDOS attack just now, it was mitigated.
Thread Rating:
  • 0 Vote(s) - 0 Average


trying to make a TCP/IP Chat Program filter_list
Author
Message
trying to make a TCP/IP Chat Program #1
hello guys , im currently making one a chat program so let's get started..
have a look at my code:
Code:
Dim Listener As New TcpListener(65535)
    Dim Client As New TcpClient
    Dim Message As String = ""
    ' Dim ListenerThread As New Thread(New ThreadStart(AddressOf Listening))

    Private Sub btnConnect_Click(sender As Object, e As EventArgs) Handles btnConnect.Click
  '  If cmbAddress.Text.Length < 4 Then
  '  MessageBox.Show("Please Enter a Valid Address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  '    Else
  '  If txtName.Text = "" Then
  ' MsgBox("Please enter a name!!", MsgBoxStyle.Critical)
  ' Else
  btnConnect.Text = "Connecting"
  Dim pingresult As String = My.Computer.Network.Ping("192.168.1.2")
  If pingresult = "True" Then
    btnConnect.Text = "Connected"
    Form15.Show()
  Else
    btnConnect.Text = "Disconnected"
    '  End If
    '  End If
  End If
    End Sub
Preview:
[Image: 9A2FDEZ.png]

form15.vb code for Chat room:
Code:
Dim Client As New TcpClient
    Dim Message As String = ""
    Dim Listener As New TcpListener(65535)
    Dim Listener1 As New TcpListener(65534)
    Dim Client1 As New TcpClient
    Dim Message1 As String = ""
    Dim IPAdd As String
    ' Dim clnt As New UNOLibs.Net.ClientClass
    ' Dim clnt2 As New UNOLibs.Net.ClientClass
    '  Dim WithEvents server As UNOLibs.Net.ServerClass
    ' Dim WithEvents server2 As UNOLibs.Net.ServerClass

    Private Sub Listening()
  Listener.Start()
  Listener1.Start()
    End Sub
    Private Sub FlatButton1_Click(sender As Object, e As EventArgs) Handles FlatButton1.Click
  Try
    Client = New TcpClient("192.168.1.2", 65535)
    Dim Writer As New StreamWriter(Client.GetStream())
    Writer.Write(Form5.txtName.Text & ":" & txtmessage.Text)
    Writer.Flush()
    RichTextBox1.Text += (Form5.txtName.Text & ":  " & txtmessage.Text) + vbCrLf
    txtmessage.Text = ""
  Catch ex As Exception
    Console.WriteLine(ex)
    Dim Errorresult As String = ex.Message
    MessageBox.Show(Errorresult & vbCrLf & vbCrLf & "Please Review Client Address", "Error Sending Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
  End Try
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  If Listener.Pending = True Then
    Message = ""
    Client = Listener.AcceptTcpClient()

    Dim Reader As New StreamReader(Client.GetStream())
    While Reader.Peek > -1
    Message = Message + Convert.ToChar(Reader.Read()).ToString
    End While
    RichTextBox1.ForeColor = Color.Black
    RichTextBox1.Text += Message + vbCrLf
  End If
  If Listener1.Pending = True Then
    Message1 = ""
    Client1 = Listener1.AcceptTcpClient()

    Dim Reader1 As New StreamReader(Client1.GetStream())
    While Reader1.Peek > -1
    Message1 = Message1 + Convert.ToChar(Reader1.Read()).ToString
    End While
    ' Form5.PicClient.Image = StringToBitmap(Message1)
  End If
    End Sub
Preview
[Image: DXgozr2.png]
now when I went to test the application I can connect and form15 will show up then when I try to send a text I get an error:
Code:
No connection could be made because the target machine actively refused it 192.168.1.2:65535

Please review Client Address
help please, what shall I do Sad

Reply

RE: trying to make a TCP/IP Chat Program #2
I haven't looked at your code yet, and I'm going on a limb here but... Have you tried forwarding that port?
"You can't send a donation to yourself."
Damn.

Reply

RE: trying to make a TCP/IP Chat Program #3
It means that there is nothing listening at that port to accept the connection. Make sure that your server software is running and accepting connections.

Reply

RE: trying to make a TCP/IP Chat Program #4
(08-19-2013, 08:18 PM)Bonfire Wrote: I haven't looked at your code yet, and I'm going on a limb here but... Have you tried forwarding that port?

yes I tried to use one of my port forwarded port and it also didn't work please help, much appreciate it !!

(08-19-2013, 08:37 PM)Xanii Wrote: It means that there is nothing listening at that port to accept the connection. Make sure that your server software is running and accepting connections.
oh!!! I wasn't listening! how dumb am I, but I got a question, if others gonna use this what port should I use :O?

Reply

RE: trying to make a TCP/IP Chat Program #5
(08-19-2013, 08:37 PM)Blackbone Wrote:
(08-19-2013, 08:18 PM)Bonfire Wrote: I haven't looked at your code yet, and I'm going on a limb here but... Have you tried forwarding that port?

yes I tried to use one of my port forwarded port and it also didn't work please help, much appreciate it !!

(08-19-2013, 08:37 PM)Xanii Wrote: It means that there is nothing listening at that port to accept the connection. Make sure that your server software is running and accepting connections.
oh!!! I wasn't listening! how dumb am I, but I got a question, if others gonna use this what port should I use :O?

It's all up to you, you make the software.

Reply

RE: trying to make a TCP/IP Chat Program #6
You might want to refer to this to find an unused port number: http://en.wikipedia.org/wiki/List_of_TCP...rt_numbers

You don't have to, but it's a suggestion.

Keep it simple.
"You can't send a donation to yourself."
Damn.

Reply

RE: trying to make a TCP/IP Chat Program #7
(08-19-2013, 08:48 PM)Bonfire Wrote: You might want to refer to this to find an unused port number: http://en.wikipedia.org/wiki/List_of_TCP...rt_numbers

You don't have to, but it's a suggestion.

Keep it simple.

I used Ports 80 & 443 seems legit Biggrin

Reply

RE: trying to make a TCP/IP Chat Program #8
(08-19-2013, 08:56 PM)Blackbone Wrote:
(08-19-2013, 08:48 PM)Bonfire Wrote: You might want to refer to this to find an unused port number: http://en.wikipedia.org/wiki/List_of_TCP...rt_numbers

You don't have to, but it's a suggestion.

Keep it simple.

I used Ports 80 & 443 seems legit Biggrin

It doesn't really matter what port you use, aslong as the server is listening on the same port as the client.
[Image: tumblr_m4vms28lYu1qj3ir1.gif]

Reply

RE: trying to make a TCP/IP Chat Program #9
I would also try to make sure to not use a port that is commonly used by something else.

Reply

RE: trying to make a TCP/IP Chat Program #10
the ports from 1 to 1024 are system reserved
use port from 49152-65535

for in depth analysis see this: http://www.iana.org/assignments/service-...bers.xhtml
[Image: Eeiygwm.png]
[Image: uiw9M7w.png][Image: Y8ausZK.gif]
[Image: 1uUyOl6.png]

Reply







Users browsing this thread: 1 Guest(s)






This forum uses Lukasz Tkacz MyBB addons.