TcpClient Issues

Sc0pe

Newcomer
Joined
Oct 15, 2004
Messages
24
OK, I have the whole thing setup and it works perfect when I use localhost as the ip. However, when I put in my ip, no one can connect to the program, including me. The messagebox pops up saying the server is not active... Any ideas?

Code:
Const READ_BUFFER_SIZE As Integer = 255
Const PORT_NUM As Integer = 9000

Private client As TcpClient
Private readBuffer(READ_BUFFER_SIZE) As Byte

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim frmConnectUser As New frmConnectUser

        Try
            client = New TcpClient("localhost", PORT_NUM)

            client.GetStream.BeginRead(readBuffer, 0, READ_BUFFER_SIZE, AddressOf DoRead, Nothing)

            Me.Show()

            AttemptLogin()
        Catch Ex As Exception
            MsgBox("Server is not active.  Please start server and try again.", _
                   MsgBoxStyle.Exclamation, Me.Text)
            Me.Dispose()
        End Try

        lstUsers.Items.Clear()
        SendData("REQUESTUSERS")
    End Sub
 
Last edited:
PlausiblyDamp said:
What is the exception that is raised? Can you ping the ip address from the client machine and get a valid response?

I have the server side and the client side on my laptop. When I use localhost to connect it works. It doesn't however when I put in my ip, and it doesn't for other users either. The exception is the client program not connecting, unless you're referring to something else.

Since the host and the client are on the same computer, that would mean pinging myself. I did it and I got a valid response. I also asked someone else to do so, they got a valid response from my ip as well...
 
Back
Top