Hi guys,

I need your help. I am working on the client-server on my application and I am unsure which one of those method that I should use for the chat server.

When I tried this:

Code:
Dim port As Int32 = 13000
Dim localAddr As IPAddress = IPAddress.Parse("127.0.0.1")

server = New TcpListener(localAddr, port)

' Start listening for client requests.
server.Start()

Try
  MessageBox.Show("connected!")

Catch ex As Exception
  'reconnect to the server
End Try


And also when I tried this:

Code:
Dim clientSocket As New System.Net.Sockets.TcpClient()
Dim serverStream As NetworkStream
clientSocket.Connect("127.0.0.1", 13000)

If clientSocket.Connected Then
  MessageBox.Show("connected!")

Else
  'reconnect to the server
End If
I found that both of these methods are the same, I can connect to the server when I use either of them. Please can you tell me which one of them is the easy way and which one of them that I should use to connect to the server, send message...etc?

Thanks in advance