473,698 Members | 2,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET: Connect and Disconnect using System.Net.Sock ets

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.Sock ets

Module Connection

Dim tcpC As New TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC.Connect("1 52.138.40.200", 6970)
Catch e As Exception
Console.WriteLi ne(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 13531
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.Sock ets

Module Connection

Dim tcpC As TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC = new TcpClient
tcpC.Connect("1 52.138.40.200", 6970)
Catch e As Exception
Console.WriteLi ne(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******** **********@TK2M SFTNGP12.phx.gb l...
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.Sock ets

Module Connection

Dim tcpC As New TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC.Connect("1 52.138.40.200", 6970)
Catch e As Exception
Console.WriteLi ne(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.Sock ets

Module Connection

Dim tcpC As TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC = new TcpClient
tcpC.Connect("1 52.138.40.200", 6970)
Catch e As Exception
Console.WriteLi ne(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******** **********@TK2M SFTNGP12.phx.gb l...
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.Sock ets

Module Connection

Dim tcpC As New TcpClient

Public Sub Connect()

'Connect from this to the server at Port 6970
Try
tcpC.Connect("1 52.138.40.200", 6970)
Catch e As Exception
Console.WriteLi ne(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
4064
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 need to be able to reuse a client socket by placing it into a pool. Unfortunately, with .NET Framework 1.1 I have no way to close a socket's connection to a remote host without disposing of the socket's resources altogether (i.e, Socket.Close()),...
2
4274
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 TcpClient to connect. Connecting, sending and receiving data, error handling, ... all works fine. The problem is when closing the connection. Now as i understand it, closing the socket works as follows: client -> tcp finish command
2
4960
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 servers such as mailenable.com returns "+OK 2222 octets", followed by many white space. It seems that my function does not understand what the server is responsing
0
1912
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 to it made in vb6. Some of the code in the server are based on the basic samples that i get from other authors. To give you an idea, the server uses sockets,
1
3864
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 to it made in vb6. Some of the code in the server are based on the basic samples that i get from other authors. To give you an idea, the server uses sockets,
5
19581
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 for the right email, and then click a link inside that email. I've seen some people suggested MAPI component, but it's missing in my complete components list (not only in the toolbar). But I see an Outlook Express component, which I suspect is...
0
372
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 my tcpC... I could not connect after i disconnect my connection... Imports System.Net.Sockets
4
1867
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: - header - return path - to - from - subject - folder it was downloaded from
9
8326
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 download a file no problem. My issues come when I try to use the same class with the same commands to access an FTP server on a UNIX box. I can connect and login just fine, but after that all my commands come back "500 'PWD': command not understood."....
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.