Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I am very impressed with the site and have already recommended it to one of my associates. I was truly impressed with the quickness in which someone actually responded to my question..."

Geography

Where in the world do Tek-Tips members come from?
ug505 (Programmer)
23 May 12 11:32
I'm trying to make a private chat between two people but I can't get it to connect. I Googled it and found out that I can use TCPListener and TCPClient. I tried it out and it won't work. I'm usually good with making programs that don't require Internet but this one does and it's bugging me. I haven't worked on the sending message part because of the connection problem. Can anyone find out why this isn't working?

CODE --> Basic

Imports System.Net.Sockets Public Class Form1 Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click Dim ClientSocket As TcpClient Me.txtLog.AppendText("Connecting...") Try ClientSocket.Connect(Me.txtIP.Text, Me.txtPort.Text) If ClientSocket.Connected = True Then Me.cmdConnect.Enabled = False Me.cmdSend.Enabled = True Me.txtLog.AppendText(vbCrLf) Me.txtLog.AppendText("Successfully connected.") Me.txtLog.AppendText(vbCrLf) Me.cmdSend.Enabled = True Me.cmdConnect.Enabled = False Else Me.txtLog.AppendText(vbCrLf) Me.txtLog.AppendText("Connection could not be established.") Me.txtLog.AppendText(vbCrLf) End If Catch ex As Exception Me.txtLog.AppendText(vbCrLf) Me.txtLog.AppendText("Error: Cannot connect.") Me.txtLog.AppendText(vbCrLf) End Try End Sub Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSend.Click End Sub Private Sub btnHost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHost.Click Dim HostSocket As New TcpListener(Me.txtPort.Text) Try Me.txtLog.AppendText("Creating new Host and Client Socket listener...") Do Until HostSocket.Pending = True HostSocket.Start(1) Loop If HostSocket.Pending = True Then HostSocket.AcceptTcpClient() HostSocket.Stop() Me.txtLog.AppendText("Connection established with client.") End If Catch ex As Exception HostSocket.Stop() End Try End Sub End Class

One computer is the hoster of the chat and one is the client connecting to the hoster of the chat.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close