|
-
Sep 23rd, 2003, 03:32 AM
#1
Thread Starter
Member
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
-
Sep 23rd, 2003, 06:07 AM
#2
Thread Starter
Member
-
Sep 23rd, 2003, 07:09 AM
#3
Thread Starter
Member
Deadline for the project is 2 days time and I yet to finish it, anyone to the rescue? Need a application than can act as a client AND a server which a click of a button. Using .NET sockets.
-
Sep 25th, 2003, 07:36 PM
#4
Thread Starter
Member
-
Sep 25th, 2003, 08:29 PM
#5
Frenzied Member
Late to the party, guess your deadline passed by now, but...
I don't see anywhere in your code where you try to send data. Maybe do a tcpClient.Send.
Check the built in help for basic working examples.
I'm trying to write a Windows Service that connects to one server and multiple clients connect to it. Haven't got it down yet, but the starting code was taken from the help. This app was written and works fine in VB6, trying to port to .NET service. I agree that it was easier (faster) with the Winsock control. Gives me something to do, anyway.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|