Hello,
Lets assume I have an instance of TCPClient.
I connect successfully and have the socket stream working.
I when call the .close() method the TCPClient instance....so far so good.
Now when I come to once again reconnect by doing as before:
MyX = New TcpClient
MyX.Connect("lo calhost", 5000)
I get an error so I catch an exception which says "Unable to read data from
transport stream".
I catch the exception in DoRead()
Why is this?
Just in case below is my connection code (the entire sub):
***********CODE FOLLOWS******** ****
'//Lets get the host name so we can later find out our IP
Dim strHostName As String = System.Net.Dns. GetHostName.ToS tring
If boxIPAddressToC onnectTo.Text = "" Or boxIPAddressToC onnectTo.Text =
"localhost" Then
'//Make new instance of TCPClient
MyX = New TcpClient
MyX .Connect("local host", 5000)
Else
End If
'//Display the time and date
DisplayText(">> Date: " & System.DateTime .Now.ToLongDate String() & vbCrLf)
DisplayText(">> Time: " & System.DateTime .Now.ToLongTime String() & vbCrLf)
'//Initialize a read stream running in its own background thread
MyAdamHonekChat terClient.GetSt ream.BeginRead( OtherUserText, 0, 1024,
AddressOf DoRead, Nothing)
'//Send some text now indicating this user has logged on
SendUserText("> > " & boxMyNickName.T ext & " is currently online.")
'Setup status of form controls ready for a new chat session
boxMyNickName.E nabled = False
boxUserText.Rea dOnly = False
boxUserTextDisp lay.ReadOnly = True
btnSendUserText .Enabled = True
boxUserText.Ena bled = True
btnSignIn.Enabl ed = False
btnChangeFont.E nabled = True
btnChangeFontCo lor.Enabled = True
'//Inform the user that they have signed-in and are online ready to chat
StatusBar.Text = "You are currently online as " & boxMyNickName.T ext & "
(Your IP: " &
(System.Net.Dns .GetHostByName( strHostName).Ad dressList(0).To String) & ")"
***********
Many thanks,
Adam 0 852 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hameed Khan |
last post by:
hi all,
i am getting some problems with my first socket
script. can any one of you point me why this is
happening. the server script suppose to accept one
connection at a time and send countdown to client
connected to it from a function through a separate
thread. and echo all the connections opened and
closed. the client script is working fine. it echoes
the countdown it recieve from server.
|
by: Droopy |
last post by:
Hi,
I try to implement a reusable socket class to send and receive data.
It seems to work but I have 2 problems :
1) I rely on Socket.Available to detect that the connection is closed (no
more data to expect). Sometimes, Socket.Available returns 0 but the other
end of the connection did not close it !
2) This class will be used by many other classes so I have to use the
|
by: Droopy |
last post by:
Hi,
I try to implement a reusable socket class to send and receive data.
It seems to work but I have 2 problems :
1) I rely on Socket.Available to detect that the connection is closed (no
more data to expect). Sometimes, Socket.Available returns 0 but the other
end of the connection did not close it !
2) This class will be used by many other classes so I have to use the
|
by: Mangabasi |
last post by:
Howdy,
I would like to use the Synthesis Toolkit for a demo. I downloaded
the STK from http://ccrma.stanford.edu/software/stk/index.html. It
seems very powerful and user friendly. There are bindings for socket
connections and TCL gui examples. I would like to get one of the demo
samples work with Python/wxPython. I am including the TCL code for
the drums demo (this was the shortest one).
Has anybody converted this to wxPython? ...
|
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...
| |
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,...
|
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...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
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
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |