TCP troubles

darknuke

Regular
Joined
Oct 3, 2003
Messages
68
Example:

Visual Basic:
    Private Sub accept()

            server = New System.Net.Sockets.TcpListener(txtReceivePort.Text)

            server.Start()

            connect = server.AcceptTcpClient

            connect.GetStream.BeginWrite(convert.toBytes(":: Connected"), 0, System.Text.Encoding.ASCII.GetByteCount(":: Connected"), Nothing, Nothing)     

    End Sub

    Private Sub somesub()

    connect.GetStream.BeginWrite(convert.toBytes(":: Received Message"), 0, System.Text.Encoding.ASCII.GetByteCount(":: Received Message"), Nothing, Nothing)   

    End Sub

In accept(), it can write to the stream just fine, but when in somesub(), it says 'the instance is not set to an object' when it tries to write.

How can I pass the connect object?
 
Last edited:
Visual Basic:
Private Sub sendMessage_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles sendMessage.KeyPress

someSub()

End Sub
 
Back
Top