Socket Help! Winsock was so much easier!
I can create a connection, but I can't send nor receive data.
Code:
Private tcpClient As tcpClient
Private tcpListener As tcpListener
Private Function DisplayText(ByVal TextToAdd As String)
txtDisplay.AppendText(TextToAdd + vbCrLf)
End Function
Private Sub txtInput_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtInput.KeyUp
If e.KeyCode = Keys.Enter And txtInput.Text <> "" Then
DisplayText(txtInput.Text)
txtInput.Text = ""
End If
End Sub
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Me.Text = "Client"
Try
tcpClient = New TcpClient()
tcpClient.Connect("127.0.0.1", 1337)
DisplayText("Connection established")
Catch ex As Exception
DisplayText(ex.ToString)
End Try
End Sub
Dim message As String = "wahahahaha"
Private Sub btnListen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListen.Click
Me.Text = "Server"
Try
DisplayText("Waiting for connection...")
tcpListener = New TcpListener(System.Net.IPAddress.Parse("127.0.0.1"), 1337)
tcpListener.Start()
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
DisplayText("Connection established")
Catch ex As Exception
DisplayText(ex.ToString)
End Try
End Sub