TCP troubles

darknuke

Well-known member
Joined
Oct 3, 2003
Messages
68
Example:

Code:
    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 by a moderator:
Code:
Private Sub sendMessage_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles sendMessage.KeyPress

someSub()

End Sub
 
Back
Top