473,320 Members | 1,949 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,320 software developers and data experts.

object instances in Custom Objects

I am creating a custom TCPDatagram object. I am using :

mTcp() as tcpClient
mNetstream() as NetworkStream

below is the actual code with my questions at the end.

Public Class TCPDatagram

Private mTcp() As TcpClient

Private mNetStream() As NetworkStream

Public Property TcpData(ByVal i As Integer) As TcpClient

Get

Return mTcp(i)

End Get

Set(ByVal Value As TcpClient)

mTcp(i) = Value

End Set

End Property

Public Property NetStream(ByVal i As Integer) As NetworkStream

Get

Return mNetStream(i)

End Get

Set(ByVal Value As NetworkStream)

mNetStream(i) = Value

End Set

End Property

Public Sub OpenDatagram(ByVal ip As String, ByVal index As Integer)

Try

'============================

ip = "192.168.155.99"

'============================

TcpData(index).Connect(ip, 4000)

NetStream(index) = TcpData(index).GetStream

Catch ex As Exception

Debug.WriteLine(ex.Message)

End Try

End Sub

Public Sub CloseDatagram(ByVal index As Integer)

Try

NetStream(index).Close()

TcpData(index).Close()

Catch ex As Exception

Debug.WriteLine(ex.Message & "," & "CloseDatagram")

End Try

End Sub

Public Sub New(ByVal index As Integer)

ReDim mTcp(index)

ReDim mNetStream(index)

End Sub

End Class 'TCPDatagram

my quetion is when i go to open the datagram through OpenDatagram, and i
pass it all the right information I am getting an instance object exception
in that procedure...but i dont know why...

my calling code instanciates the class using new, I am not inheriting from
TcpClient because I am not extending it, i am just trying to make a
connection object that uses it...any help here?

Thanks

Eric
Nov 20 '05 #1
2 1111
On Sat, 18 Oct 2003 12:09:14 -0400, "Eric Cathell"
<ec******@mountaire.com> wrote:

Public Sub New(ByVal index As Integer)

ReDim mTcp(index)

ReDim mNetStream(index)
' (Add these lines in place)
Dim counter As Integer
For counter = 0 To index
mTcp(counter) = New TcpClient()
Next
End Sub

End Class 'TCPDatagram

my quetion is when i go to open the datagram through OpenDatagram, and i
pass it all the right information I am getting an instance object exception
in that procedure...but i dont know why...
You had allocated an array to _hold_ TcpClient objects. You had NOT
created any TcpClient objects. i.e. mTcp() was an array containing a
load of Nothings.
my calling code instanciates the class using new, I am not inheriting from
TcpClient because I am not extending it, i am just trying to make a
connection object that uses it...any help here?


You class doesn't look like a TCPDatagram - it looks more like a
connection pool. Or are you intending to implement some kind of
server?

Rgds,

Nov 20 '05 #2
>You class doesn't look like a TCPDatagram - it looks more like a
connection pool. Or are you intending to implement some kind of
server?


I didnt really know what to call it...hehe...It probably could be considered
a connection pool. I have several printers that are connected to my network
via client bridges...they are used to print palletmarkers. I have a thread
setup for each printer, this part of the code is where I am opening up the
connection...checking the printer status then printing the label...I am
refining my code to hopefully make the process as fast as possible...before
i was doing several connections and it was being handled inside the monitor
instead of as a seperate entity....

thanks for the info...I would not have caught that...i figured i needed to
use the New tcpClient somewhere...just didnt know where...

Thanks again...
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Virendra Verma | last post by:
This sounds weird, but I am looking for separate behaviors for destruction of a const and non-const object. I am trying to develop a smart/auto pointer class for writing objects to disk...
2
by: lpw | last post by:
I have dilligently reviewed FAQ-lite Section 3.2, "How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc." The only...
15
by: randyr | last post by:
I am developing an asp.net app based on a previous asp application. in the asp applications global.asa file I had several <object id="id" runat="server" scope="scope" class="comclass"> tags for...
4
by: Luke Matuszewski | last post by:
Here are some questions that i am interested about and wanted to here an explanation/discussion: 1. (general) Is the objectness in JavaScript was supported from the very first version of it (in...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
15
by: Sam Kong | last post by:
Hello! I got recently intrigued with JavaScript's prototype-based object-orientation. However, I still don't understand the mechanism clearly. What's the difference between the following...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
4
by: Michael Maes | last post by:
Hi, On closing our App, we get following 'InvalidComObjectException': "COM object that has been separated from its underlying RCW cannot be used" The App has been upgraded from .Net1.1 to...
5
by: JH | last post by:
Hi I found that a type/class are both a subclass and a instance of base type "object". It conflicts to my understanding that: 1.) a type/class object is created from class statement 2.) a...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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

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.