Hi all,
I am writing an application that is acting as
an web client, that needs to connect to
multiple servers. The web servers are small
embedded web servers that talk to a host
of other electronics. I need my app to
pole each web server to check for changes.
I can connect to the two device I have currently,
first one then the other.
However, if I then attempt to connect to the first
web server again it fails!
This is my code to connect to the server
Private Sub btnConnect_Clic k(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnConnect.Clic k
m_Client.Close( )
m_Client = Nothing
m_Client = New TcpClient(IP_Ad dr, PORT_NUM)
If m_Client.GetStr eam.CanRead = False Then
Debug.WriteLine ("Can't read from stream")
Else
Debug.WriteLine ("Can read from stream")
End If
m_Client.GetStr eam.BeginRead(m _ReadBuffer, 0,
READ_BUFFER_SIZ E, AddressOf DoRead, Nothing)
End Sub
When the connection is remade no data is sent back to
DoRead and the connection is not made.
DoRead is used as a asynchronous reader for the stream.
Private Sub DoRead(ByVal ar As IAsyncResult)
Dim bytesRead As Integer
Dim message As String
Try
bytesRead = m_Client.GetStr eam.EndRead(ar)
If bytesRead < 1 Then
Debug.WriteLine ("No bytes received on doRead")
Debug.Flush()
Else
message = Encoding.ASCII. GetString(m_Rea dBuffer, 0,
bytesRead - 2)
ProcessCommands (message)
End If
' Start a new asynchronous read into readBuffer.
m_Client.GetStr eam.BeginRead(m _ReadBuffer, 0,
READ_BUFFER_SIZ E, AddressOf DoRead, Nothing)
Catch ex As SocketException
MessageBox.Show ("DoRead: " & ex.Message &
ControlChars.Cr Lf & ex.ErrorCode)
Catch ex As Exception
MessageBox.Show ("DoRear: " & ex.Message)
End Try
End Sub
Any help with why this is not working, or suggestions
as to how I can connect and disconnect as a tcpClient would
be most appreciated.
Many thanks,
Jason. 0 923 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Virgil Green |
last post by:
An associate has asked me to take a look a problem he's having with starting
mysql. I thought I'd give it a shot to learn some more about mySQL before
having him turn it over to someone more knowledgeable than I. But I have to
ask here first.
Attempting to connect to the database via mysqladmin or mysql results in the
error (paraphrased) "Cannot connect to local database using socket
"/var/lib/mysql/mysql.sock".
That is the path to...
|
by: Cory Nelson |
last post by:
I've created a new C++ sockets library - small, cross-platform, IPv4
and IPv6. If anyone would like to critique it, I'd appreciate it.
Doesn't support the more exotic protocols - only TCP and UDP. It also
lacks get/setsockopt and ioctl, but those may be added in the future.
There is no webpage for it yet, I plan on making one once I'm 100% sure
of everything. For now the source is available here:
http://dev.int64.org/netx.zip
PS....
|
by: Dave Edwards |
last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot
figure out how to fill a dataset with the same query but run against
multiple SQL servers, the query , table structure and username, password etc
will be exactly the same for each server, the only thing that will change is
the server name. Idealy I would like to get the server names from a seperate
dataset so there could be any number of servers, allthough in...
|
by: Jason L James |
last post by:
Hi all,
as a VB.Net programmer I am finding it difficult to
find a text on implementing sockets to communicate
with an embedded web server.
Does anyone know of a good resource, either text book
or on-line that I should refer to. I also need to
implement multi-threading to enable me to communicate
with several embedded devices at the same time.
|
by: Ronodev.Sen |
last post by:
the way my program needs to go is --
1) open a socket and listen on it
2) moment a client connects to the socket - process some data (by
sending it to another machine), get the result and send it back to the
SAME socket - the data isnt a large value (measured in bytes rather
than MB or GB)
i TRIED thinking of this in the Asynchronous way - BeginReceive - then
pass to the OnClient Connected handler, which calls a Wait For Data
| |
by: jasonsgeiger |
last post by:
From: "Factor" <jasonsgeiger@gmail.com>
Newsgroups: microsoft.public.in.csharp
Subject: Multiple Clients, One port
Date: Wed, 19 Apr 2006 09:36:02 -0700
I'm been working with sockets for a short while now using a server
program a former coworker started. The program listens on a port for
incomming connections. When a valid connection is made (we send this
init string into the socket from the clients) the server closes the
socket so...
|
by: keerthyragavendran |
last post by:
hi
i'm downloading a single file using multiple threads...
how can i specify a particular range of bytes alone from a single
large file... for example say if i need only bytes ranging from
500000 to 3200000 of a file whose size is say 20MB...
how do i request a download which starts directly at 500000th byte...
thank u
cheers
|
by: zaferaydin |
last post by:
Hi,
i have a Socket based application that works well. The application connects remote servers and getting data from them.
When i try to read data from 20-30 servers at the same time, i works well. But when i try to read 500-1000 server at the same time, it works so slow. The connection requests wait so much although i use async socket methods.
I have suspicion that windows limits the number of sockets can be created at the same...
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |