469,336 Members | 5,839 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Winsock active-x requires object reference?

Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

The compiler complains that it is expecting a reference to
an object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData
into an array of bytes?

Richy.

Nov 15 '05 #1
8 4148
Richy,

Why are you using an ActiveX control when you could be using the built in
functionailty of the .NET Framework classes? Look into the classes Socket,
TcpClient & TcpListener in the help. They will be able to do what you want
to do without any interop nastiness and the overhead of ActiveX.

HTH
Kieran

"Richy" <ri*************@yahoo.co.uk> wrote in message
news:28****************************@phx.gbl...
Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

The compiler complains that it is expecting a reference to
an object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData
into an array of bytes?

Richy.

Nov 15 '05 #2
found someone with the same problem.

http://www.experts-
exchange.com/Programming/Programming_Languages/C_Sharp/Q_20
697280.html

problem is, what is the solution.

-----Original Message-----
Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

The compiler complains that it is expecting a reference toan object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData
into an array of bytes?

Richy.

.

Nov 15 '05 #3
I have tried that, but it blocks when it is receiving data.

The Active-X provides a Data Arrival Event, preventing my
application from hanging.

What is the point of having Active-X if you cannot use
them?
-----Original Message-----
Richy,

Why are you using an ActiveX control when you could be using the built infunctionailty of the .NET Framework classes? Look into the classes Socket,TcpClient & TcpListener in the help. They will be able to do what you wantto do without any interop nastiness and the overhead of ActiveX.
HTH
Kieran

"Richy" <ri*************@yahoo.co.uk> wrote in message
news:28****************************@phx.gbl...
Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

The compiler complains that it is expecting a reference to an object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData into an array of bytes?

Richy.

.

Nov 15 '05 #4

"Richy" <ri*************@yahoo.co.uk> wrote in message
news:28****************************@phx.gbl...
Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

While I agree with Kieran, you should be using the framework classes, there
is absolutly no need to interop with the winsock activex control, but here
is my suggestion anyawy (also, is type really supposed to be the object
type? doesn't sound right to me):
object o = (object)buffer;
axWinsock1.GetData(ref o,buffer.GetType(),10);

I don't know if it will work, don't have time to try, but thats often what
you have to do in other interop situations.
The compiler complains that it is expecting a reference to
an object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData
into an array of bytes?

Richy.

Nov 15 '05 #5

"Richy" <ri*************@yahoo.co.uk> wrote in message
news:1e****************************@phx.gbl...
I have tried that, but it blocks when it is receiving data.

The Active-X provides a Data Arrival Event, preventing my
application from hanging.

What is the point of having Active-X if you cannot use
them?


One word, LEGACY. Its not there for any other reason, imho. They are messy
to use when managed equivilents exist.

As for blocking IO, thats why various BeginXXX methods exist, they are
asynchronous and you can provide callbacks that are called when the
asynchronous method finishes.

For TcpClient, for example, returns a NetworkStream, NetworkStream has a
BeginRead method that is asynchronous, most of the other classes should have
it as well, read up on it.
-----Original Message-----
Richy,

Why are you using an ActiveX control when you could be

using the built in
functionailty of the .NET Framework classes? Look into

the classes Socket,
TcpClient & TcpListener in the help. They will be able to

do what you want
to do without any interop nastiness and the overhead of

ActiveX.

HTH
Kieran

"Richy" <ri*************@yahoo.co.uk> wrote in message
news:28****************************@phx.gbl...
Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

The compiler complains that it is expecting a reference to an object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData into an array of bytes?

Richy.

.

Nov 15 '05 #6

thanks Kieran & Daniel for the input - guess it's time to
move onto the framework classes ;-)
-----Original Message-----
Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

The compiler complains that it is expecting a reference toan object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData
into an array of bytes?

Richy.

.

Nov 15 '05 #7

"Richy" <ri*************@yahoo.co.uk> wrote in message
news:2a****************************@phx.gbl...

thanks Kieran & Daniel for the input - guess it's time to
move onto the framework classes ;-)


np, hope I didn't sound to harsh, I'm really rather tired, -_-
-----Original Message-----
Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

The compiler complains that it is expecting a reference

to
an object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData
into an array of bytes?

Richy.

.

Nov 15 '05 #8
Richy,
Sounds like a plan to me :) They really are much cleaner to use and probably
more efficient.

Hope you've got it working now anyway.

Kieran

"Richy" <ri*************@yahoo.co.uk> wrote in message
news:2a****************************@phx.gbl...

thanks Kieran & Daniel for the input - guess it's time to
move onto the framework classes ;-)
-----Original Message-----
Hi,

I'm using a winsock active-x component in a C# program.

I can send data using the following:

byte[] buffer = new byte[10];
axWinsock1.SendData( buffer);

But to receive isn't as easy.

The prototype is show below:

axWinsock1.GetData( ref object data, object type, object
MaxLen)

I cannot pass buffer in as a parameter, see below.

axWinsock1.GetData( ref buffer, buffer.GetType(), 10 );

The compiler complains that it is expecting a reference

to
an object as the first parameter. But it doesn't
complain about the send equivalent which is also of type
object, see below:

axWinsock1.SendData( object data )

Any one know how I would receive using axWinsock1.GetData
into an array of bytes?

Richy.

.

Nov 15 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Niels Borg | last post: by
1 post views Thread by Chris Thompson | last post: by
1 post views Thread by Yu Chai | last post: by
5 posts views Thread by kc | last post: by
1 post views Thread by Nicolas Ghesquiere | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.