By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,282 Members | 1,548 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,282 IT Pros & Developers. It's quick & easy.

VB.NET: Connect and Disconnect using System.Net.Sockets

P: n/a
Say i have declare a module for connection and two buttons...

one button has the method connect() and
the other has the method disconnect()....

how do i actually connect after i had disconnect my tcpC...
I could not connect after i disconnect my connection...

Imports System.Net.Sockets

Module Connection

Dim tcpC As New TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC.Connect("152.138.40.200", 6970)
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub

Public Sub Disconnect()
tcpC.Close()
End Sub

End Module

Thanks

--

toytoy - http://www.visual-basic-data-mining.net/forum

************************************************** *******
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I don't have access to a system to try this on, but I think what is
happening is you have to create a new tcpclient every time you want to open
the connection. I'm new at this but give it a try. Just trying to help
out. Someone smarter might want to verify this.

Imports System.Net.Sockets

Module Connection

Dim tcpC As TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC = new TcpClient
tcpC.Connect("152.138.40.200", 6970)
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub

Public Sub Disconnect()
if not tcpC is nothing then
tcpC.Close()
tcpC = nothing
end if
End Sub

End Module

"http://www.visual-basic-data-mining.net/forum" <si******@gmail.com> wrote
in message news:%2******************@TK2MSFTNGP12.phx.gbl...
Say i have declare a module for connection and two buttons...

one button has the method connect() and
the other has the method disconnect()....

how do i actually connect after i had disconnect my tcpC...
I could not connect after i disconnect my connection...

Imports System.Net.Sockets

Module Connection

Dim tcpC As New TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC.Connect("152.138.40.200", 6970)
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub

Public Sub Disconnect()
tcpC.Close()
End Sub

End Module

Thanks

--

toytoy - http://www.visual-basic-data-mining.net/forum

************************************************** *******

Nov 21 '05 #2

P: n/a
I don't have access to a system to try this on, but I think what is
happening is you have to create a new tcpclient every time you want to open
the connection. I'm new at this but give it a try. Just trying to help
out. Someone smarter might want to verify this.

Imports System.Net.Sockets

Module Connection

Dim tcpC As TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC = new TcpClient
tcpC.Connect("152.138.40.200", 6970)
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub

Public Sub Disconnect()
if not tcpC is nothing then
tcpC.Close()
tcpC = nothing
end if
End Sub

End Module

"http://www.visual-basic-data-mining.net/forum" <si******@gmail.com> wrote
in message news:%2******************@TK2MSFTNGP12.phx.gbl...
Say i have declare a module for connection and two buttons...

one button has the method connect() and
the other has the method disconnect()....

how do i actually connect after i had disconnect my tcpC...
I could not connect after i disconnect my connection...

Imports System.Net.Sockets

Module Connection

Dim tcpC As New TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC.Connect("152.138.40.200", 6970)
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub

Public Sub Disconnect()
tcpC.Close()
End Sub

End Module

Thanks

--

toytoy - http://www.visual-basic-data-mining.net/forum

************************************************** *******

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.