VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
Go Back  Xtreme Visual Basic Talk > > > VB.NET: Connect and Disconnect using System.Net.Sockets


Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2004, 03:40 AM
toytoy's Avatar
toytoy toytoy is offline
Regular
 
Join Date: Jul 2004
Posts: 81
Default 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...

Code:
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
Reply With Quote
  #2  
Old 11-12-2004, 04:25 AM
excaliber's Avatar
excaliberVB.NET: Connect and Disconnect using System.Net.Sockets excaliber is offline
Senior Contributor

* Expert *
 
Join Date: Nov 2002
Location: Ohio, USA
Posts: 1,828
Default

Try these links:

http://www.eggheadcafe.com/articles/20020323.asp
http://msdn.microsoft.com/library/de...ClassTopic.asp

What exactly do you mean by not being able to disconnect after connecting? Did it throw an error? Did it do nothing?
__________________
RandomIRC - Your neighborhood's friendly IRC channel (irc.randomirc.com - #code)

"Perl - The only language that looks the same before and after RSA encryption."
Reply With Quote
  #3  
Old 11-12-2004, 10:44 AM
toytoy's Avatar
toytoy toytoy is offline
Regular
 
Join Date: Jul 2004
Posts: 81
Default

[that means:

1 step: when i start the program, it can connect to the server through the "Connect" Buton...

2 steps: when i click the "Disconnect" button, the connection is then closed...

3 steps: However the connection could not connect again when i click the "Connect" button the second time..

the connection just break out with no exception...
my string that i sent over, cannot get cross it the second time...
that means it could only get connected once..
Reply With Quote
  #4  
Old 11-12-2004, 12:45 PM
excaliber's Avatar
excaliberVB.NET: Connect and Disconnect using System.Net.Sockets excaliber is offline
Senior Contributor

* Expert *
 
Join Date: Nov 2002
Location: Ohio, USA
Posts: 1,828
Default

Ok, few questions then. What are you connecting to? Is it your own server? Another server (protocol?).

It could be, if it is your server code, that you are not reallocating the socket when done with it. Basically, whenever a client closes, you need to free up that socket by calling a close() then listen() to get it started again.

If its not your code, im not sure.
__________________
RandomIRC - Your neighborhood's friendly IRC channel (irc.randomirc.com - #code)

"Perl - The only language that looks the same before and after RSA encryption."
Reply With Quote
  #5  
Old 11-13-2004, 08:57 PM
toytoy's Avatar
toytoy toytoy is offline
Regular
 
Join Date: Jul 2004
Posts: 81
Default

Quote:
Originally Posted by excaliber
Ok, few questions then. What are you connecting to? Is it your own server? Another server (protocol?).

It could be, if it is your server code, that you are not reallocating the socket when done with it. Basically, whenever a client closes, you need to free up that socket by calling a close() then listen() to get it started again.

If its not your code, im not sure.
yeah...it is from the server protocol (IP address and port)

I am not working at the server code but the client side connecting to the server..
Reply With Quote
  #6  
Old 11-14-2004, 07:43 AM
excaliber's Avatar
excaliberVB.NET: Connect and Disconnect using System.Net.Sockets excaliber is offline
Senior Contributor

* Expert *
 
Join Date: Nov 2002
Location: Ohio, USA
Posts: 1,828
Default

Quote:
Originally Posted by toytoy
yeah...it is from the server protocol (IP address and port)

I am not working at the server code but the client side connecting to the server..
No, what kind of server are you connecting to? HTTP? FTP? Is it your own server code (you are creating the code youreself) or is it precompiled binary code (say, Apache web server)?
__________________
RandomIRC - Your neighborhood's friendly IRC channel (irc.randomirc.com - #code)

"Perl - The only language that looks the same before and after RSA encryption."
Reply With Quote
  #7  
Old 11-14-2004, 08:22 AM
toytoy's Avatar
toytoy toytoy is offline
Regular
 
Join Date: Jul 2004
Posts: 81
Default

oh...Apache Tomcat web server to test...

But I only know that i just need to connect through the IP and port to the server...the rest i am not too sure..

Does it matter a lot since i only need IP and Port to connect...

Last edited by toytoy; 11-14-2004 at 08:39 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
 
VB.NET: Connect and Disconnect using System.Net.Sockets
VB.NET: Connect and Disconnect using System.Net.Sockets
 
-->