473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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

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
2 13484
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: integragreg | last post by:
I apologize in advance if I am posting to the wrong group, but at least one of my questions is related to Platform Invoke in C#. I am using .NET Framework 1.1, and for improved performance, I...
2
by: Silby | last post by:
I've been messing around with sockets for a bit and i got most of it down (i think). The server side is an asynchronous tcp socket listener with sits and waits for data. The client side uses...
2
by: Guoqi Zheng | last post by:
Dear sir, I am writing a pop3 component myself. After sending "RETR" command, I use below function to get the response from Pop server. For some pop servers, it works ok, but some other pop...
0
by: richard | last post by:
OS: Winxp and Win2003 Visual Basic.NET 2003 MS-SQL Server 2000 hey all I am a newbie in vb.net but i have managed to build a simple chat server in vb.net using socket and a client connecting...
1
by: richard | last post by:
OS: Winxp and Win2003 Visual Basic.NET 2003 MS-SQL Server 2000 hey all I am a newbie in vb.net but i have managed to build a simple chat server in vb.net using socket and a client connecting...
5
by: sophocles the wise | last post by:
I am researching this topic without a satisfactory solution so far. Please let me know which is the easiest way to receive email using VB code. All I need is to test source address or subject line...
0
by: http://www.visual-basic-data-mining.net/forum | last post by:
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...
4
by: Brett | last post by:
I'd like any references to code that demonstrates how to download email messages from a mail server strictly through VB.NET. I'd also like to split each message into seperate components such as: ...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.