.NET Framework - Winsock 6 control in VB.NET

Asked By kimiraikkonen
26-Mar-08 11:55 PM
Hi,
As you know there's no mswinsck.ocx ActiveX control in VB.NET 2005 or
08 by default, but it exists in VB6. However i can add this old
control to my VB 2005 toolbox with no problem by extracting from VB6's
cabinets, but when using inside my project, i get some syntax problems
which runs fine in VB6. I do not want to go back VB6.

Is it healthy and supported using mswinsck.ocx Winsock control in
VB.NET projects?

And is System.Net.Sockets the unique alternative for this Winsock
control and is it completely equilavent?

Thanks
AxMSWinsockLib.DMSWinsockControlEvents
(1)
System.Net.Sockets
(1)
System.EventArgs
(1)
EventArgs
(1)
VB.NET
(1)
VB
(1)
Button1.Click
(1)
Button3.Click
(1)
  Tom Shelton replied...
24-Mar-08 03:39 PM
You want to use System.Net.Sockets.  The winsock control sucked in VB6,
and it sucks even worse in .NET ;)

--
Tom Shelton
  kimiraikkonen replied...
26-Mar-08 11:56 PM
On Mar 24, 9:39=A0pm, Tom Shelton

Dear Tom, Thanks for the information. However actually my intention
was to program a small application that consist of 2 parts, server and
client for sending any file over the WAN, not LAN. Do you have a
simple code that demonstrates that on .NET using sockets class?

Thanks

Onur G=FCzel
  Tom Shelton replied...
24-Mar-08 04:05 PM
Sure...  MS has a fairly good set of examples.  On both sync and async
usage (start here):

http://msdn2.microsoft.com/en-us/library/b6xa24z5.aspx

There are articles off of here, for both server and client usage.
--
Tom Shelton
  kimiraikkonen replied...
26-Mar-08 11:56 PM
On Mar 24, 10:05=A0pm, Tom Shelton

s
s
6,


Thanks, i'll check and there are similar samples in 101 samples page.
I saw some good Winsock 6 samples using mswinsck.ocx but it's hard to
get the working code in .NET environment, beleive. Maybe there's
a .NET wrapper for legacy Winsock 6, even it can be added to .NET
toolbox as ActiveX control, surprise.

Regards
  kimiraikkonen replied...
01-Apr-08 11:46 PM
or
6's
ems



Tom, to update, i added Winsock 6 ActiveX control (mswinsck.ocx) to
use in VB.NET to accomplish a basic chat operation on the same
machine(127.0.0.1) and here is an exception that Winsock 6 throws when
sending text string (data) from client to server:

Full client code:

And it fails at:
also made no difference.

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
tcpClient.RemotePort =3D 1001
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Try
tcpClient.RemoteHost =3D Trim(TextBox3.Text)
tcpClient.Connect()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button3.Click
tcpClient.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
If Not TextBox2.Text =3D "" Then
tcpClient.SendData(CStr(TextBox2.Text.ToString))
End If
End Sub

Private Sub tcpClient_DataArrival(ByVal sender As System.Object,
ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent)
Handles tcpClient.DataArrival
Dim strData As String
tcpClient.GetData(strData)
MsgBox(strData)

End Sub
End Class

Is it a coding error or because Winsock 6's behaviour in VB.NET?

Thanks
  Tom Shelton replied...
31-Mar-08 12:13 PM
To be completely honest, there are a number of reasons that I could not
even begin to answer this question...  Starting with the fact, that I
didn't use the Winsock control in VB.CLASSIC - I always used the raw
winsock api for all of my socket communication - so, I really don't know
much about that particular control.  Second, I don't have a copy of VB6
or it's documentation installed on any of my current systems.  I long
ago abandoned VB of any flavor - and currently do all my work in C#.
And the last reason, is that I don't think you should even bother going
down this route - since the .NET framework as very good support of
tcp/ip communication (both asyncronous and syncronous) built in.

Maybe someone else here will be able to answer your question?

--
Tom Shelton
help
Use of Mid Statement in VB.Net .NET Framework Hi All If anyone has the time, I think feedback on the following eg aba format. The beauty of the old VB6 Mid statement (which is available in VB.Net) is that it allows me to replace n chars at a specified position in a mfRecordType Mid(buffer, pointer, MyFields.mfTransactionType ) = "AB" pointer + = mfTransactionType 'etc etc There appears no native VB.Net equivalent to this method. The StringBuilder Class does not have this method either. It should as used above) for the Mid Statement in VS (any language)? Thanks for your time. VB.NET Discussions ASCIIEncoding (1) System.Runtime.CompilerServices (1) System.Text.StringBuilder (1) MyFields.mfTransactionType (1) MyFields
I'm told that VB6 code, when well written, can be ten times faster than vb.net, but that if its badly written it can be ten times slower. Is that correct my code will be quite well written, and I don't want to move to vb.net if well written VB6 code is ten times faster. Have I been told the truth? Or do I need to look into this further? Mike VB.NET Discussions Vista (1) StringBuilder (1 VB.NET (1) VB (1) Visual (1) Correct (1) Report (1) Check (1) Hi Mike, Great to
effective apps in vb6, I am trying to see if it is worthwhile relearning for vb.net. I have vb express 2008. One of the things I want to do is read object. How can I do it in dot.net? How can I do this is vb.net? VB.NET Discussions Visual Studio 2010 (1) Visual Studio (1) Silverlight (1) Windows 7 (1) Office (1 there were no solutions to the print problem. Cheers StrandElectric wrote : It is possible in VB.NET using the built in file io functions, but I would suggest you not do this
ms-help: / / MS.VSCC.v90 / dv_commoner / local / redirect.htm?keyword = "6A50421D-15FE-4896-8A1B-2EC21E9037B2"' VB.NET Discussions System.Windows.Forms.Label (1) ROoTU8Qao3uGcAQ (1) Visual Studio (1) AFQjCNE6dCe (1) DparQZWWzXw2Q (1) Linux (1) ADO.NET (1) VB.NET (1) The fact is that "converting" VB 6 code to VB .NET is often not worth the trouble. VB .NET is not just the new version of VB, it is an entirely new language running
1) Visual Studio (1) Outlook (1) Linux (1) Excel (1) BackgroundWorker (1) W. Wolf (1) VB NET (1) Schmidt <sss@online.de> schrieb im Beitrag Gerade wegen der positiven Stimmen würde ich bei '[VB6]' bleiben (besser noch nur '[VB]'; es unterscheidet von allem bis auf VB NET, und dafür sollte dann, denke ich, '[VBNET]' verwendet werden). '[VBclassic]' ist m.E. zu lang vbnet Meiner Meinung nach sollten wir uns dann aber nicht wundern, wenn vor allem die VB.NET-Newcomer dann zuerst bei uns "anklopfen" . . . so sehr mir der Grund- gedanke dahinter: (ein schlichtes im September den RfD einzureichen, damit ab Januar 2011 die Newsgroup auch funktioniert. F?r VB.NET gibt es das MS-Forum, was ?ber die Brigde genutzt werden kann. Da w?rde