Results 1 to 6 of 6

Thread: System.Net.Sockets Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Location
    USA
    Posts
    1

    System.Net.Sockets Help

    I need some help with System.Net.Sockets.

    I'm trying to convert this code that was written in Visual Basic 6.0 to Visual Basic Express.

    Here is the old code:

    Code:
    frmMain.Winsock.Send "Reg" & txtUsername & ":" & txtPassword & ":" & txtEmailAddress & vbFormFeed
    What would be the equivalent of the same code using System.Net.Sockets in Visual Basic Express. I have already setup a connection and everything.

  2. #2
    Frenzied Member Campion's Avatar
    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: System.Net.Sockets Help

    There's a .NET based Winsock available here that you may want to look into:

    http://www.codeproject.com/vb/net/winsockdotnet.asp

    I haven't had much time to do anything with it yet, but it SHOULD be basically equivilant to the Winsock used in VB6, but with some other added functionality thanks to the .NET framework.

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: System.Net.Sockets Help

    To send data, you need to write to the networkstream.
    Heres an example
    VB Code:
    1. 'SomeClient is a System.Net.Sockets.TcpClient class
    2. Try
    3. Using sw As New IO.StreamWriter(SomeClient.GetStream)
    4.      sw.Write("Hey")
    5. End Using
    6. Catch ex As Exception
    7. MessageBox.Show(ex.ToString)
    8. End Try
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: System.Net.Sockets Help

    Quote Originally Posted by Campion
    There's a .NET based Winsock available here that you may want to look into:

    http://www.codeproject.com/vb/net/winsockdotnet.asp

    I haven't had much time to do anything with it yet, but it SHOULD be basically equivilant to the Winsock used in VB6, but with some other added functionality thanks to the .NET framework.

    Great answer thanks dude you helped me out and stopped me threading )

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: System.Net.Sockets Help

    Quote Originally Posted by r1chyb
    Great answer thanks dude you helped me out and stopped me threading )
    But why would you want to use that? If the answer is "Because then the code is already written for me", then one could ask why you are programming in the first place. You will have to package extra stuff along with your project and make it more bulky and you will never learn the techniques of socket programming which is very good to know. The .Net framework already provides us with a great number of classes to do whatever we want, why download extra classes?

    This Winsock.Net control is apparently made by a VB6 programmer that misses the winsock control in .Net. An attempt to make .Net more like VB6..bah.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  6. #6
    Frenzied Member Campion's Avatar
    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: System.Net.Sockets Help

    Quote Originally Posted by Atheist
    This Winsock.Net control is apparently made by a VB6 programmer that misses the winsock control in .Net. An attempt to make .Net more like VB6..bah.
    You may have a point there, but when you download and look at the source code, it's a great way to figure out how it's done in .NET.

    I'm trying to learn it the .NET way as well based on the threads I've found on this site, but so far, it's proving to be way too confusing and headache inducing, and ends up resulting in massive failure.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width